Jump to content
Sign in to follow this  
red79bronco

Verify a windows user is logged on

Recommended Posts

red79bronco

I need to check the status of a computer before activating a script.

I am executing an AutoIT script using psexec on a list of computers.

How can I check the remote computer to see if the computer is at a windows logon screen?

I thought I could check a window title, and exit the script if the Welcome to Windows text was in the screen, but that does not seem to be the case.

Share this post


Link to post
Share on other sites
ptrex

@red79bronco

A simple check on wether he/she is running the "Explorer.exe" Process will do.

If not running he/she will be at the logon window.

You can do this using WMI. There are lot"s of examples on how to do a remote check on a process.

I hope this get's you going.

regards

ptrex

Share this post


Link to post
Share on other sites
red79bronco

thanks for pointing me in the right direction.

Regards,

red79bronco

Share this post


Link to post
Share on other sites
red79bronco

thanks, again, for the nudge.

If ProcessExists("explorer.exe") Then

;Perform some action for logged on user

Else

;Wait for user to log on

EndIf

Regards,

red79bronco

Share this post


Link to post
Share on other sites
exodius

thanks, again, for the nudge.

If ProcessExists("explorer.exe") Then

;Perform some action for logged on user

Else

;Wait for user to log on

EndIf

Regards,

red79bronco

You could also have a script that basically does a batch run of pslist (in the same pstools as psexec) for that list of computers and parse out your results then take action based on it...

Share this post


Link to post
Share on other sites
spudw2k

Another way, using WMI, is to query the UserName property from the Win32_ComputerSystem class.

$host = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("SELECT UserName from Win32_ComputerSystem")
For $objItem in $colItems
    msgbox(0,"",$objItem.UserName)
Next

Name of a user that is logged on currently. This property must have a value. In a terminal services session, UserName returns the name of the user that is logged on to the consolenot the user logged on during the terminal service session.

Edited by spudw2k

Share this post


Link to post
Share on other sites
exodius

Another way, using WMI, is to query the UserName property from the Win32_ComputerSystem class.

$host = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("SELECT UserName from Win32_ComputerSystem")
For $objItem in $colItems
    msgbox(0,"",$objItem.UserName)
Next
That'll work as long as the computer is pingable, otherwise you're going to have a very long timeout on that WMI call...

Share this post


Link to post
Share on other sites
spudw2k

That'll work as long as the computer is pingable, otherwise you're going to have a very long timeout on that WMI call...

Resolvable, not pingable.

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  

×