Find current user logged into the desktop

  • Thread starter Thread starter Greg Long
  • Start date Start date
G

Greg Long

Is there a way to find out what user is currently logged in to the desktop.
or see all users currently logged into the system then be able to
differentiate which ones are term svc users? .. I need to be able to do this
with a registry query or a script
 
That is a great tool and gets me half way to were i want to be. I now need a
way to diferenciate from term svc users vs desktop users
 
I fould this fow showing user loged into desktop of a machine


Set argsNamed = WScript.Arguments.Named
Set argsUnnamed = WScript.Arguments.Unnamed
strUsage=""
strUsers=""
If argsNamed.exists("?") Then Call usage
If not argsNamed.exists("computer") Then strusage=strusage&"missing
/computer:computer name"&vbcrlf
If strusage <> "" Then Call usage
strComputer = argsNamed.item("computer")

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
If not IsNull(objComputer.UserName) Then
strusers=strusers&"User:"&objComputer.UserName&vbcrlf
End If
Next
If Len(strusers) > 1 Then
Wscript.Echo strusers
Else
wscript.echo "Not Found"
End If

Sub Usage
wscript.echo "showdeskuser usage"
wscript.echo StrUsage
wscript.echo "cscript showdeskuser.vbs /computer:computername"
wscript.quit
End Sub
 
Back
Top