Wednesday, March 25, 2009

WMI is broken on Windows XP Service Pack 2

Question/Issue:

VBScript is failing on executing a WMI query, e.g.
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Solution:

To repair WMI, open a command prompt (you will need to have administrative privileges) and run the following command:

rundll32 wbemupgd, UpgradeRepository

Then, open the services snap-in (services.msc) and restart the Windows Management Instrumentation service.

If the above fails, you may need to reinstall WMI. To do this, use the following command:

rundll32.exe setupapi,InstallHinfSection WBEM 132 %windir%\inf\wbemoc.inf

NOTE: This may require you to provide the Windows XP SP2 source media (either via CD-Rom or network share).

No comments: