IBM Support

Script to Repair WMI and recompile MOF files

How To


Summary

Script to allow for WMI repair with the additional ability to recompile MOF files

Objective

Recover operating systems where issue traced to WMI and/or MOF files causing issues such as high CPU and \or memory utilization.

Environment

Windows Operating system 

Steps

Copy and paste into notepad and save as a .bat file. Run as Administrator on identified system.

 

:: START OF SCRIPT

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape0"

sc config "IA Manager" start= disabled

sc config "IA Provider" start= disabled

sc config "CcmExec" start= disabled

taskkill /IM IAManager.exe /F

net stop "IA Manager"

taskkill /IM IAConsumer.exe /F

taskkill /IM IAProvider.exe /F

net stop "IA Provider"

taskkill /IM CcmExec.exe /F

net stop CcmExec

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape1"

:: Retrieve list of MOF, MFL files excluding any that contain "Uninstall" "Remove" or "AutoRecover", and retrieve DLL File List

dir /b /s %systemroot%\system32\wbem*.mof | findstr /vi "Uninstall" | findstr /vi "Remove" | findstr /vi "AutoRecover" > %temp%\MOF-list.txt

dir /b /s %systemroot%\system32\wbem*.mfl | findstr /vi "Uninstall" | findstr /vi "Remove" > %temp%\MFL-List.txt

dir /b /s %systemroot%\system32\wbem*.dll > %temp%\DLL-List.txt

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape2"

:: Set Services to manual and stopped state for Microsoft Storage Spaces (SMPHost) and Volume Shadow Copy (VSS) prior to repository reset

:: If these are not set to manual and are not stopped, could have volume issues on some WMI queries in the future such as bitlock Volume Status

sc config vss start= demand

sc config smphost start= demand

sc stop SMPHost

sc stop vss

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape3"

:: Disable and Stop winmgmt service (Windows Management Instrumentation)

sc config winmgmt start= disabled

net stop winmgmt /y

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape4"

:: This line resets the WMI repository, which renames current repository folder %systemroot%\system32\wbem\Repository to Repository.001

:: Repository will automatically be recreated and rebuilt

winmgmt /resetrepository

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape5"

:: These DLL Registers will help fix broken GPUpdate

regsvr32 /s %systemroot%\system32\scecli.dll

regsvr32 /s %systemroot%\system32\userenv.dll

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape6"

:: These dll registers help ensure all DLLs for WMI are registered:

for /F "tokens=*" %%t in (%temp%\DLL-List.txt) do regsvr32 /s %%t

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape7"

:: Enable winmgmt service (WMI)

sc config winmgmt start= auto

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape8"

:: Start Windows Management Instrumentation (Winmgmt)

for /F "tokens=3 delims=: " %%H in ('sc query "winmgmt" ^| findstr " STATE"') do (

if /I "%%H" NEQ "RUNNING" (

net start "winmgmt"

)

)

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape9"

:: Timeout to let WMI Service start

timeout /t 15 /nobreak > NUL

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape10"

:: Parse MOF and MFL files to add classes and class instances to WMI repository

for /F "tokens=*" %%A in (%temp%\MOF-List.txt) do mofcomp %%A

for /F "tokens=*" %%B in (%temp%\MFL-List.txt) do mofcomp %%B

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape11"

:: Cleanup temp files created

if exist %temp%\MOF-List.txt del %temp%\MOF-list.txt

if exist %temp%\MFL-List.txt del %temp%\MFL-list.txt

if exist %temp%\DLL-List.txt del %temp%\DLL-list.txt

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "Etape12"

sc config "IA Manager" start= auto

sc config "IA Provider" start= auto

sc config "CcmExec" start= auto

DEL "C:\Program Files (x86)\Interact\Res\Mof\AlertConfXP.mof" /F

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO SCRIPT_WMI /D "FIN"

:: END OF SCRIPT

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB66","label":"Technology Lifecycle Services"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SSTIPK","label":"Microsoft Windows"},"ARM Category":[{"code":"a8mKe000000004NIAQ","label":"Windows"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":""}]

Document Information

Modified date:
17 November 2025

UID

ibm17251563