Sign in to follow this  
Followers 0
billb3

Determine if user is logged on...

4 posts in this topic

Hi All,

Fairly new user here, have been writing lot of scripts over the past few weeks...but I'm stumped right now.

I am deploying packages using Everdream(www.everdream.com) and want my package to determine if a user is logged into the computer. If a user is logged on, I want it to popup a dialog before installing. If nobody is logged on, I want it to run my installer right away.

I found this code, but this only gets some information out of the registry...and doesn't determine if that user is currently logged in. Any ideas? Thanks!

--Bill

CODE
Const $HKEY_LOCAL_MACHINE = 0x80000002

Dim $strKeyPath, $strValueName, $strValue

$strComputer = "localhost"

$objRegistry=ObjGet("winmgmts:\\" & $strComputer & "\root\default:StdRegProv")

$strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon"

$strValueName = "DefaultUserName"

$objRegistry.GetStringValue ($HKEY_LOCAL_MACHINE, $strKeyPath, $strValueName, $strValue)

$localuser = $strValue

Share this post


Link to post
Share on other sites



@UserName will return the name of the currently logged on user. I am not sure what it will return if no-one is loggen on.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

That is what I was looking for, didn't know that existed. Thanks!

Share this post


Link to post
Share on other sites

When deploying packages with Everdream, the @Username was returning "SYSTEM"...since that is the user the process runs as...

Instead, I used the "ProcessExists()" function and checked for "explorer.exe".

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  
Followers 0