Jump to content

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


Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

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

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