JustScriptIt
Technical User
I am creating a script such that it deletes a registry value.
First, I make sure I can ping it.
Then, I make sure I can connect to registry value.
Out of 20 computers, 9 of them are pingable, and two of them can connect to registry value.
However, out of curiosity, I rdp'd into one of the computers whose registry I cannot access. Turns out, I can authenticate to them.
How is it possible to authenticate to a computer, yet not access the registry object?
Here is main part of script
and here is error handling code
Please advise? Or, is there another way to determine whether we can authenticate to a cmmputer.
Thanks!
First, I make sure I can ping it.
Then, I make sure I can connect to registry value.
Out of 20 computers, 9 of them are pingable, and two of them can connect to registry value.
However, out of curiosity, I rdp'd into one of the computers whose registry I cannot access. Turns out, I can authenticate to them.
How is it possible to authenticate to a computer, yet not access the registry object?
Here is main part of script
Code:
If Ping(strComputer) then
wscript.echo "We can ping " & strComputer & " resolving to " & strName
'Can we connect to registry?
On Error Resume Next
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
If (Err.Number <> 0) Then
HandleError()
strError = "Cannot connect to registry"
Else
wscript.echo "No registry error " & strComputer
wscript.echo
End If 'corresponds with If (Err.Number <> 0)
End if 'corresponds with If Ping
and here is error handling code
Code:
Sub HandleError()
On Error Goto 0
Err.Clear
bErrorFound = True
End Sub
Please advise? Or, is there another way to determine whether we can authenticate to a cmmputer.
Thanks!