I'm trying to run the following VBScript code on a Win2k SP4:
strComputer = "."
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
It works on XP and Win7 without problems, but on this 2k box I get the following error:
C:\test_wmi.vbs(3, 1) (null): 0x8004100E
The error description is: Namespace specified cannot be found.
When I query the namespaces on root, using this code:
strComputer = "."
Set objSWbemServices = GetObject("winmgmts:\\" & strComputer & "\root")
Set colNameSpaces = objSwbemServices.InstancesOf("__NAMESPACE")
For Each objNameSpace In colNameSpaces
Wscript.Echo objNameSpace.Name
Next
I get this:
DEFAULT
SECURITY
WMI
directory
aspnet
As far as I have read, CIMV2 namespace should be there. Any ideas???
Thanks!
yorch.
I was on Windows Server 2003, Service Pack 2, and yorch's solution didn't work for me. Finally I found this page, and followed the instructions for Server 2003:
For Windows Server 2003 Use the following command to detect and repair a corrupted WMI Repository:
rundll32 wbemupgd, RepairWMISetup