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

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.bat contains:

@echo off
set key=HKLM\System\CurrentControlSet\Services
set 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>nul
pushd %systemroot%\system32\wbem
if exist Repository RD /S /Q Repository
if not exist %file% goto swmi
for /f "Tokens=*" %%a in ('type %file%') do (
 net start %%a
call :wmi>nul 2>&1
if exist %file% del /q %file%
goto :EOF
for /f "Tokens=*" %%x in ('reg query %1 /V DependOnService^|find /i "winmgmt\"') do (
 set OK=Y
goto :EOF
set work=%1
set work=%work:HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\=%
@echo %work%>>%file%
net stop %work%
goto :EOF
net start winmgmt

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.