P
Piotr M.
Hi,
I'm looking for advice.
I wrote a simple script, which returns a user name who is log on, it's
working when on remote computer, user with adiministrator privileges is log
on.
But if simple user is log on, result of this script is empty.
I checked user permission in WMI Control Console, user has full access.
How to resolve this problem?
Piotr M.
' Check to see if the computer name or IP address is entered on the command
line
if WScript.Arguments.count < 1 then
' Computer name not enter by command line - get the name or IP
strComputer = InputBox("Enter the computer's name or IP address to check W
h o I s A t")
Call showuser(strcomputer)
Else
For Each strcomputer in wscript.arguments
Call showuser(strcomputer)
Next
end if
Function showuser(strComputer)
' Open a ref to WMI
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
' Check to see anybody if logged on
if isnull(objcomputer.username) then
Wscript.Echo "No user is logged onto " & objComputer.name
else
Wscript.Echo "User " & objComputer.UserName & " Is logged onto " &
objComputer.name
End if
Next
End Function
I'm looking for advice.
I wrote a simple script, which returns a user name who is log on, it's
working when on remote computer, user with adiministrator privileges is log
on.
But if simple user is log on, result of this script is empty.
I checked user permission in WMI Control Console, user has full access.
How to resolve this problem?
Piotr M.
' Check to see if the computer name or IP address is entered on the command
line
if WScript.Arguments.count < 1 then
' Computer name not enter by command line - get the name or IP
strComputer = InputBox("Enter the computer's name or IP address to check W
h o I s A t")
Call showuser(strcomputer)
Else
For Each strcomputer in wscript.arguments
Call showuser(strcomputer)
Next
end if
Function showuser(strComputer)
' Open a ref to WMI
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
' Check to see anybody if logged on
if isnull(objcomputer.username) then
Wscript.Echo "No user is logged onto " & objComputer.name
else
Wscript.Echo "User " & objComputer.UserName & " Is logged onto " &
objComputer.name
End if
Next
End Function