Saboath Posted March 25, 2009 Share Posted March 25, 2009 Hey guys, I'm searching for a way to get only the last logged in user of a PC. I have a huge list of computers that I need to go through and check who the last person to log into them was and I figure AutoIT is the perfect tool to help me do just that! Thanks, Saboath. Link to comment Share on other sites More sharing options...
MrMitchell Posted March 25, 2009 Share Posted March 25, 2009 I've always used registry query against '"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName' From DOS it will output: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon DefaultUserName REG_SZ username If you go that route you would have to run that command using a DOS prompt into a stream, then parse it out to get the username. Seems like AutoIt should have a Macro for that or something (if ran locally on each PC), no luck from the help file? Hopefully someone will come along with a better answer, but on the bright side this should technically work from one PC as long as all PCs are on a domain or at least networked appropriately to allow you access to registry. Link to comment Share on other sites More sharing options...
Saboath Posted March 25, 2009 Author Share Posted March 25, 2009 I hadnt thought of getting it from the registry!!! I can just do a RegRead and output the key for each entry! Its always the obvious stuff I miss! Thanks MrMitchell. Link to comment Share on other sites More sharing options...
Saboath Posted March 25, 2009 Author Share Posted March 25, 2009 (edited) Just to put your idea into effect for your reference: #include <Constants.au3> $computer = "computer1" $username = RegRead("\\" & $computer & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName") MsgBox(0, "Username...", "Username is " & $username) Edited March 25, 2009 by Saboath Link to comment Share on other sites More sharing options...
MrMitchell Posted March 25, 2009 Share Posted March 25, 2009 Heh cool, I've actually never done this with AutoIt, thank you. Link to comment Share on other sites More sharing options...
Saboath Posted March 25, 2009 Author Share Posted March 25, 2009 Yay, I posted a question and then taught you something.. i'm starting to feel like a real member of this forum now! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now