JSI Tip 9771. How do I resolve Windows Management Instrumentation errors due to a corrupted WMI Repository?

Jerold Schulman

September 22, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today


If WMI applications/scripts error, or no longer function, you may have a corrupted WMI repository. I have scripted WMIRepository.bat to correct the corruption.

The syntax for using WMIRepository.bat is:

WMIRepository

WMIRepository.bat contains:

@echo offsetlocal ENABLEDELAYEDEXPANSIONset key=HKLMSystemCurrentControlSetServicesset file="%TEMP%WMIRepository_%RANDOM%.tmp"if exist %file% del /q %file%for /f "Tokens=*" %%a in ('reg query %key%^|find "HKEY_LOCAL_MACHINE"') do ( set OK=N set svc="%%a" call :quiet !svc!>nul 2>&1 if "!OK!" EQU "Y" call :depend !svc!)net stop winmgmt@ping -n 4 127.0.0.1>nulpushd %systemroot%system32wbemif exist Repository RD /S /Q Repositorypopdif not exist %file% goto swmifor /f "Tokens=*" %%a in ('type %file%') do ( net start %%a):swmicall :wmi>nul 2>&1if exist %file% del /q %file%endlocalgoto :EOF:quietfor /f "Tokens=*" %%x in ('reg query %1 /V DependOnService^|find /i "winmgmt"') do ( set OK=Y)goto :EOF:dependset work=%1set work=%work:HKEY_LOCAL_MACHINESystemCurrentControlSetServices=%@echo %work%>>%file%net stop %work%goto :EOF:wminet start winmgmt



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like