Find current user logged into the desktop

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
 
G

Greg Long

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
 
G

Greg Long

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top