Hi

Is there a way to find out the windows logon username from a dos-promt (ex with a tool) when the promt is started as LocalSystem?
This is on a Windows XP system.

I'm going to us the username to get the SID of the user so I can change the login user / current_users registry-settings.
The tool I will use i PSGetSID from Sysinternals to find the SID.
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
I'm going to us the username to get the SID of the user so I can change the login user / current_users registry-settings.

I'm a bit puzzled why you pursue this route, don't your users ever log on (so you can hit them with the logon script)?

You can use psloggedon utility to see who's currently logged on to the system...

Or, see if this piece of code can help you:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web%20WinBatch/UDF~-~UDS~Library%20Get~Current~User~List.txt
Answered 08/22/2006 by: revizor
Third Degree Blue Belt

Please log in to comment
0
Thanks revizor,

but our users dont have local administrator rights. So when we push software to our users it running in the context of the localsytsem.
Since it's localsystem, the hkey_current user will not be the logged in users.

Espen
Answered 08/22/2006 by: espen
Senior Yellow Belt

Please log in to comment
0
Do you care if the HKCU settings go to all users or only to specific ones on a given PC?
I could suggest:
a) creating self-healing msi
b) pushing "RunOnce" script to change HKCU
c) using custom group policy templates

Out of curiosity, what is supposed to trigger software install in your case? Are you engaging SMS, or anything alone those lines?
Answered 08/23/2006 by: revizor
Third Degree Blue Belt

Please log in to comment
0
By using WMI script this could be achieved.
The owner of the explorer.exe process would be the user currently logged in.
If the explorer.exe process could not be found then this would state that now user is currently logged in.

strComputer = "."
strUser = ""
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")

For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
If objProcess.Name = "explorer.exe" Then
strUser = strNameOfUser
Exit For
End If
Next
Answered 08/23/2006 by: AngelD
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity