Mr. Tweak - Windows Network & Admin Tweaks

Windows network, systems, and software Administration Tips & Tricks


4 comments Exchange WMI Errors - WMI Repository Clear & Reinstall Script

The WMI repository on one of our Exchange 2003 servers recently became corrupted, interrupted outgoing mail handling, and flooded the event logs. After some research I found the corruption isn’t entirely uncommon on Windows Server 2003 or even Windows XP systems. It is indicated by event ID’s 40, 42, 47, 63 from the WinMgmt process, event ID 3006 from the LoadPerf process, and event ID 9098 from the ExchangeSA and MAD monitoring processes. Trying to track a message in the Exchange message tracking center also displayed error code 8004100e.

I confirmed it was a WMI error by running WBEMTEST (just type “wbemtest” into the run dialog). Then click “Connect…” and try to connect to “root\microsoftexchangev2″. Should connecting to that path fail, try to connect to “root\cimv2″. If that works then WMI needs to be cleared and reregistered on the server. The script below is configured to close the Windows Management process, clear the repository, reinstall WMI, and restart the process - which should fix the errors on Windows Server or XP without a reboot. (Thanks to Luke Edson for the basis of this script. The script makes heavy use of the mofcomp compiler, see Microsoft’s description of mofcomp utility.)


WMI Repair Script (run as .BAT file):

net stop winmgmt
c:
cd %windir%\system32\wbem
rd /S /Q repository
regsvr32 /s %systemroot%\system32\scecli.dll
regsvr32 /s %systemroot%\system32\userenv.dll
mofcomp cimwin32.mof
mofcomp cimwin32.mfl
mofcomp rsop.mof
mofcomp rsop.mfl
for /f %%s in (’dir /b /s *.dll’) do regsvr32 /s %%s
for /f %%s in (’dir /b *.mof’) do mofcomp %%s
for /f %%s in (’dir /b *.mfl’) do mofcomp %%s
mofcomp -n:root\cimv2\applications\exchange wbemcons.mof
mofcomp -n:root\cimv2\applications\exchange smtpcons.mof
mofcomp exmgmt.mof
mofcomp exwmi.mof
net start winmgmt


4 Responses to “Exchange WMI Errors - WMI Repository Clear & Reinstall Script”

  1. Brian Repinski, on July 18th, 2006 at 2:02 pm, said:

    Fantastic! Worked great and solved my problem. Thank you so much!

  2. Mike Bijon, on July 20th, 2006 at 3:17 pm, said:

    Thanks Brian - hopefully it helped you shave some time off what could have been a long day of scripting or phone support.

  3. Eryk K., on October 24th, 2007 at 12:53 pm, said:

    I keep getting an error with shaderapidx9.dll, and I’ve tried this script and the problem still persists, any help would be greatly appreciated.

  4. Isaac H, on February 22nd, 2008 at 2:08 am, said:

    This batch file will solve the problem of \\.\root\cimv2 returned 8004100E or invalid name space error 8004100E

Comment on this post below


You can leave a response, or trackback from your own site.