Sign in to follow this  
Followers 0
Saboath

How to get last / current user that is logged into a computer

6 posts in this topic

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! :D

Thanks,

Saboath.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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! :D

Thanks MrMitchell.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Saboath

Share this post


Link to post
Share on other sites

Heh cool, I've actually never done this with AutoIt, thank you.

Share this post


Link to post
Share on other sites

Yay, I posted a question and then taught you something.. i'm starting to feel like a real member of this forum now! :D

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0