Jump to content

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


Recommended Posts

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.

Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...