Verifying the State of the CIM Repository
If you think that the CIM Repository might be corrupted, you can verify its state by running the following scripts on the computer.
The following script lists all the namespaces:
'Namespaces.vbs Set loc = CreateObject("WbemScripting.SWbemLocator") wscript.echo "root"GetNamespaces "root", 1 Sub GetNamespaces(Path, Level) Set WbemServices = loc.ConnectServer( , path ) Set Namespaces = WbemServices.ExecQuery("Select * From __Namespace") For Each Namespace in Namespaces Wscript.Echo Space(5*level) & Namespace.Name GetNamespaces path & "\" & Namespace.Name, Level+1 Next End Sub
The following script lists all the providers:
'Providers.vbs Set shell = CreateObject("WScript.Shell") Set loc = CreateObject("WbemScripting.SWbemLocator") GetNamespaces "root", 1 Sub GetNamespaces(Path, Level) Set WbemServices = loc.ConnectServer( , path ) Set Namespaces = WbemServices.ExecQuery("Select * From __Namespace") For Each Namespace in Namespaces Set Providers = WbemServices.ExecQuery("Select * From __Provider") For Each Provider in Providers key = "HKEY_CLASSES_ROOT\CLSID\" & Provider.CLSID DLL="" if Provider.CLSID<>"" Then On Error Resume Next DLL=shell.RegRead( key & "\InProcServer32\" ) If DLL="" Then DLL=shell.RegRead( key & "\LocalServer32\" ) On Error Goto 0 End If WScript.Echo Provider.Name & ", " & DLL Next GetNamespaces path & "\" & Namespace.Name, Level+1 Next End Sub
Your computer might have many providers defined, often in multiple namespaces. To identify each unique provider, the output from the previous script can be piped to the SORT command and directed to a text file for easier reading. This can be done with the following command:
Providers | Sort > Temp.txt
The following script provides a count of all the classes in each namespace:
'ClassCounts.vbs Set loc = CreateObject("WbemScripting.SWbemLocator") GetNamespaces "root", 0, "root"Sub GetNamespaces(Path, Level, NamespaceName) Set WbemServices = loc.ConnectServer( , path ) Set classes=WbemServices.SubClassesOf WScript.Echo Space(5*Level) & NamespaceName & ": " & classes.count Set Namespaces = WbemServices.ExecQuery("Select * From __Namespace") For Each Namespace in Namespaces GetNamespaces Path & "\" & Namespace.Name, Level+1, Namespace.Name Next End Sub
For More Information
Did you find this information useful? Please send your suggestions and comments about the documentation to smsdocs@microsoft.com.