Windows logon user / interactive user
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.
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
Answers (4)
Please log in to answer
Posted by:
revizor
18 years ago
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
Posted by:
espen
18 years ago
Posted by:
revizor
18 years ago
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?
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?
Posted by:
AngelD
18 years ago
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
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.