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

Re: Functionality Lost by Charles

Charles
Mon Dec 29 10:54:36 CST 2003

Additional information:

I have it working still on another machine. The machines that is failing is
running WindowsXP SP1 with all of the latest patches and Office 2003 Pro.
The machine that it is working on is WindowsXP SP1 with all the latest
patches and Office 2000 Premium SR1. What has changed with WMI with an
Office upgrade that prevents me from auditing other machines using the WMI
interface?

Charles

"Charles J. Palmer" <cjpalmer@outsourceimsg.com> wrote in message
news:OgUqIRhzDHA.1680@TK2MSFTNGP12.phx.gbl...
> 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
>
>



Re: Functionality Lost by Charles

Charles
Tue Dec 30 14:45:47 CST 2003

Found the problem to be related to DCOM. DCOM had been disabled by an
install in the last month. The RegObj was lost when I upgraded Office but I
was able to redownload it and reinstall it to get that functionality back.

Charles

"Charles J. Palmer" <cjpalmer@outsourceimsg.com> wrote in message
news:uuEtyxizDHA.560@TK2MSFTNGP11.phx.gbl...
> Additional information:
>
> I have it working still on another machine. The machines that is failing
is
> running WindowsXP SP1 with all of the latest patches and Office 2003 Pro.
> The machine that it is working on is WindowsXP SP1 with all the latest
> patches and Office 2000 Premium SR1. What has changed with WMI with an
> Office upgrade that prevents me from auditing other machines using the WMI
> interface?
>
> Charles
>
> "Charles J. Palmer" <cjpalmer@outsourceimsg.com> wrote in message
> news:OgUqIRhzDHA.1680@TK2MSFTNGP12.phx.gbl...
> > 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
> >
> >
>
>