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
2. Stop the WMI service
net stop winmgmt
3. Salvage and reset the repository
winmgmt /salvagerepository C:\WINDOWS\System32\wbem
winmgmt /resetrepository C:\WINDOWS\System32\wbem
4. Re-enable the WMI service
sc config winmgmt start= auto
5. 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
2. Stop the WMI service
net stop winmgmt
3. Rename the existing repository
rename "%WINDIR%\system32\wbem\repository" "repository.bkup"
4. Re-enable the WMI service
sc config winmgmt start= auto
5. Restart Windows
shutdown /f /r /t 0
6. Delete repository backup if no issues (optional)
rmdir /S /Q "%WINDIR%\system32\wbem\repository.bkup"