I have a script that connects to a domain and gets a list of computers. It
then processes that list to perform various functions like checking Admin
group membership and disabling services. One of my test functions is to
determine if a machine is a workstation or not. In October, that code worked
fine. But when I went to run it this month, it stopped working. The code is
as follows:
Function IsWorkstation(CompName)
'On Error Resume Next
Dim
objRegistry,objRegKey,strProdTypeVal,strProdTypeKey,objWMIRegistry,strProdTy
peKeyWMI
IsWorkstation = False
strProdTypeKey =
"\HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ProductOptions\"
Set objRegistry = CreateObject("RegObj.Registry")
If err.Number <> 0 Then wscript.echo CompName & " RegObj.Registry not
established. Error:" & err.Number & ":" & err.description : err.clear
Set objRegistry = objRegistry.RemoteRegistry(CompName)
If err.Number <> 0 Then wscript.echo CompName & " RemoteRegistry not
established. Error:" & err.Number & ":" & err.description : err.clear
Set objRegKey = objRegistry.RegKeyFromString(strProdTypeKey)
If err.Number <> 0 Then wscript.echo CompName & " RegRead not successful.
Error:" & err.Number & ":" & err.description : err.clear
strProdTypeVal = objRegKey.Values("ProductType").Value 'Here we get the
ProductType value
If err.Number <> 0 Then
wscript.echo CompName & " ObjReg did not work. Trying WMI: Error: " &
err.Number & ":" & err.description : err.Clear
strProdTypeKeyWMI = "SYSTEM\CurrentControlSet\Control\ProductOptions\"
Set objWMIRegistry =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & CompName &
"\root\default:StdRegProv")
If err.Number <> 0 Then wscript.echo CompName & " WMIRegistry Failed with
Error: " & err.Number & ":" & err.description : err.Clear
objWMIRegistry.GetStringValue
HKLM,strProdTypeKeyWMI,"ProductType",strProdTypeVal 'Here we get the
ProductType value
If err.Number <> 0 Then wscript.echo CompName & " WMIRegistry Read Failed
with Error: " & err.Number & ":" & err.description : err.Clear
Set objWMIRegistry = nothing
End If
wscript.echo CompName & " is of type " & strProdTypeVal
If strProdTypeVal = "WinNT" Then 'The computer is an NT Workstation, not a
Server
IsWorkstation = True
End If
Set objRegKey = nothing
Set objRegistry = nothing
End Function
The RegObj.Registry probably broke because I upgraded my office from XP to
2003. I am not as concerned about that portion of the code as I am about the
fall-back method. At the time I wrote the code, we still had a large number
of non-Win2K machines so WMI was not an option in all cases. Now, the
percentage is very low and the WMI method would be the preferred method.
But, for some reason, the WMI is not working anymore. When I execute the
above code against a remote machine, I get the following error:
Workstationtest.vbs(18, 3) (null): Remote calls are not allowed for this
process.
This used to work. It appears that some patch has closed the WMI door that
would allow me to read the registry. Maybe I have to provide authentication
now? Any guidance on this problem would be greatly appreciated.
Charles J. Palmer