Repairing and rebuild WMI repository

How to repair or rebuild the WMI repository in Windows via CMD

Repairing the repository

Run the following commands in CMD

  1. Disable the WMI service
sc config winmgmt start= disabled
  1. Stop the WMI service
net stop winmgmt
  1. Salvage and reset the repository
winmgmt /salvagerepository C:\WINDOWS\System32\wbem
winmgmt /resetrepository C:\WINDOWS\System32\wbem
  1. Re-enable the WMI service
sc config winmgmt start= auto
  1. Restart Windows
shutdown /f /r /t 0

Rebuilding the repository

Run the following commands in CMD

  1. Disable the WMI service
sc config winmgmt start= disabled
  1. Stop the WMI service
net stop winmgmt
  1. Rename the existing repository
rename "%WINDIR%\system32\wbem\repository" "repository.bkup"
  1. Re-enable the WMI service
sc config winmgmt start= auto
  1. Restart Windows
shutdown /f /r /t 0
  1. Delete repository backup if no issues (optional)
rmdir /S /Q "%WINDIR%\system32\wbem\repository.bkup"

Tags: #Os #Windows