Jump to content

Verify a windows user is logged on


Recommended Posts

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.

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

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...
Link to comment
Share on other sites

  • 2 weeks later...
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...