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?

slhck
  • 223,558
  • 70
  • 607
  • 592
Decker97
  • 185
  • 1
  • 1
  • 7

5 Answers5

6

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
karel
  • 13,390
  • 26
  • 45
  • 52
  • helped me on windows 10 – codeDom Jun 04 '20 at 18:20
  • Thanks! Executing these steps helped me to solve the Sourcetree startup problem on Windows 7 Pro 64bit (caused by WMI problem) described here: https://community.atlassian.com/t5/Sourcetree-questions/Sourcetree-installer-Failed-to-start-System-Management/qaq-p/2196885 – klor Feb 26 '23 at 19:30
4

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.

Journeyman Geek
  • 127,463
  • 52
  • 260
  • 430
2

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

Sharken
  • 1,651
  • 11
  • 6
1

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?
xavier_fakerat
  • 2,502
  • 2
  • 13
  • 24
0

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.

I say Reinstate Monica
  • 25,487
  • 19
  • 95
  • 131