Jump to content
Sign in to follow this  
AcidicChip

How do I determine if the computer is at the login screen?

Recommended Posts

AcidicChip

I know you can get the current logged in user's name, etc. However I am looking for a way to determine if the computer is at the Windows XP Login/Switch User screen?

Edited by AcidicChip

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

does this help?

$value = RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "AltDefaultUserName")
Msgbox(64, "Value", $value)

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
AcidicChip

Hi,

does this help?

$value = RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "AltDefaultUserName")
Msgbox(64, "Value", $value)

So long,

Mega

That seems to just tell me the default name, and returns it wether I'm at the login screen or actively logged in.

I basically want to know when I log out or go into the switch user screen, so that I can just see my lights red to know that my computer isn't open for someone else to just sit down and use it.

Share this post


Link to post
Share on other sites
ptrex

@AcidicChip

Maybe this can help you out.

; ------ SCRIPT CONFIGURATION ------
$strUserDN = "<UserDN>" ; e.g. cn=rallen,ou=Sales,dc=rallencorp,dc=com
; ------ END CONFIGURATION ---------

 $objUser = ObjGet("LDAP://" & $strUserDN)
 $objLogon = $objUser.Get("lastLogonTimestamp")
 
$intLogonTime = $objLogon.HighPart * (2^32) + $objLogon.LowPart 
$intLogonTime = $intLogonTime / (60 * 10000000)
$intLogonTime = $intLogonTime / 1440

ConsoleWrite ("Approx last logon timestamp: " & $intLogonTime )

Regards,

ptrex

Share this post


Link to post
Share on other sites
AcidicChip

@ptrex

I can't seem to get that to work, I keep getting this error

C:\Documents and Settings\Chance\Desktop\LightFX\LightFX.au3 (20) : ==> Variable must be of type "Object".:

$objLogon = $objUser.Get("lastLogonTimestamp")

$objLogon = $objUser^ ERROR

Share this post


Link to post
Share on other sites
ptrex
AcidicChip

@ptrex

I'm not looking for domain users or anything like that being logged in.

I guess I should clarify what I want to do.

How can I detect if the computer is at the login/user switch screen or not?

Share this post


Link to post
Share on other sites
Selmak

How can I detect if the computer is at the login/user switch screen or not?

In principle this would work:

if WinExists ( 'Program Manager') then

$userAuthenticated=1

else

$userAuthenticated=0

endif

The only thing is, to be of any use your script would have to run as a system service, otherwise it will be terminated when the user logs-off, defeating the purpose. Might be possible with the srvany utility.

On a similar question, does anyone know how to tell if the screensaver is running? I believe it is possible to do this with a (fairly complex) call to user.exe, but just wondered if I'm overlooking an easier way.

Edited by Selmak

Share this post


Link to post
Share on other sites
jefhal

Hi ptrex-

The problems that I have with this method is that:

a. you have to know the user name

b. you only get the login time, but still do not know if the user logged off

There are threads all over the web on this very difficult issue. I usually check to see if a machine is in use before taking control of it with Dameware. However, the data I get back is often wrong. I use psloggedon from sysinternals (now microsoft), and I have recently tried by checking sessions on the main server, but this is incredibly slow.

The one solution that people end up offering is to write a script(s) that creates a database of users logging on and logging off computers. Even this method is not foolproof, for example, when a user just shuts down the computer with the power button. The database shows him logged on, but he has already left the building!

jefhal

; ------ SCRIPT CONFIGURATION ------
$strUserDN = "<UserDN>" ; e.g. cn=rallen,ou=Sales,dc=rallencorp,dc=com
; ------ END CONFIGURATION ---------

 $objUser = ObjGet("LDAP://" & $strUserDN)
 $objLogon = $objUser.Get("lastLogonTimestamp")
 
$intLogonTime = $objLogon.HighPart * (2^32) + $objLogon.LowPart 
$intLogonTime = $intLogonTime / (60 * 10000000)
$intLogonTime = $intLogonTime / 1440

ConsoleWrite ("Approx last logon timestamp: " & $intLogonTime )

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites
MHz

I know you can get the current logged in user's name, etc.

@Username normally comes up empty when no one is logged on.

Share this post


Link to post
Share on other sites
AcidicChip

Is there some sort of object class, window title/text i can look for that would determine that the computer is at the login/user switch screen?

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  

×