Jump to content

Determine if user is logged on...


billb3
 Share

Recommended Posts

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

Link to comment
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.


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

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