Sorry, couldn't think of a better title.
I have this script intended to see if somebody is logged onto a remote PC.
If so (under certain circumstances), I open up a reminder prompt on that PC.
I am using what I take to be a standard generic method, and it -did- work.
Problem is that now, it shows that nobody is logged in, even when they are.
It works OK when I query my machine and the other machines in my office, but
not the remote machines. I am wondering if it involves some obscure network
setting or something.
The guts of the routine are below.
=======================
strComputer = "whs147"
On Error Resume Next
Dim strUser
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
strUser = "NA"
For Each objComputer in colComputer
If cstr(objComputer.UserName) <> "null" Then
strUser = cstr(objComputer.UserName)
End If
Next
If strUser <> "NA" Then
MsgBox "User logged on: " & strUser
Else
MsgBox "Nobody logged on"
End If