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?
05 Answers
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:
- Disable and stop the winmgmt service.
- Remove or rename
C:\Windows\System32\wbem\repository. - Enable and start the winmgmt service.
- Open a cmd prompt as Administrator.
- In the cmd prompt navigate to
C:\Windows\System32\wbem\ - Run the command
for /f %s in ('dir /b *.mof') do mofcomp %sThis will take a minute or so to complete. - 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.
1Another 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\wbemRe-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
I run into corrupt WMI fairly often working with client systems. I was very frustrated by the acknowledgement from MS that WMI has issues and not getting releif with any suggested fix.
Last year I found this procedure and it works EVERY TIME!
Open a Microsoft PowerShell window. Type the following commands and press enter after each command
net stop winmgmt ren c:\windows\system32\wbem\repository c:\windows\system32\wbem\repository_old net start winmgmt cd c:\windows\system32\wbem lodctr /r Check and make sure all services are running. A reboot is not required at this point, but it is the fastest way to assure that all services restart.