Repair WMI on Windows 7

I had a problem with my Microsoft SQL Server 2008, importing data and generating scripts, so I decided to uninstall it. When I tried to remove it, I got an error from the check screen. The WMI service is corrupted, so I need a way to reset the WMI service.

Platform: Windows 7 64bit

I did try winmgmt /resetrepository

to no effect.

Short of reinstalling Windows, what can I do?


If its a file level corruption you could probably try the sfc /scannow command - this will check and replace any system files that are damaged.


To fully rebuild the WMI Repository follow these steps:

  1. Disable and stop the winmgmt service.
  2. Remove or rename C:\Windows\System32\wbem\repository.
  3. Enable and start the winmgmt service.
  4. Open a cmd prompt as Administrator.
  5. In the cmd prompt navigate to C:\Windows\System32\wbem\
  6. Run the command for /f %s in ('dir /b *.mof') do mofcomp %s This will take a minute or so to complete.
  7. Run the command for /f %s in ('dir /b en-us\*.mfl') do mofcomp en-us\%s

I had the same problem and using Repair WMI from Tweaking.com fixed it.


Another handy option to fix WMI using a WMI Fixer Tool (WMI Fixer.ps1) created by Guido Basilio de Oliviera and is freely available.

This tool is based on Windows Powershell and Windows Forms:

cd /d % windir% \System32\Wbem
net stop winmgmt

winmgmt /clearadap
winmgmt /kill
winmgmt /unregserver
winmgmt /regserver
winmgmt /resyncperf

del % windir% \System32\Wbem\Repository /Q
del % windir% \System32\Wbem\AutoRecover /Q

for % % i in (* .dll) do Regsvr32 -s % % i
for % % i in (* .mof, * .mfl) do Mofcomp % % i
wmiadap.exe /Regsvr32
wmiapsrv.exe /Regsvr32
wmiprvse.exe /Regsvr32

net start winmgmt

Or alternatively..

  • Disable and stop the WMI service.       
  • Run the following commands.     

    Winmgmt /salvagerepository %windir%\System32\wbem

          (then)      

    Winmgmt /resetrepository %windir%\System32\wbem

     

  • Re-enable the WMI service and then reboot the PC to see how it goes.

         You could also try rebuilding the repository if the above fails:

  • Disable and stop the WMI service.

       

  • Rename the repository folder (located at %windir%\System32\wbem\repository) to repository.old.

  • Re-enable the WMI service.

         

  • Reboot the PC

Acknowledgements

  1. WMI corrupt - how to reinstall/repair?