Jump to content

Start Script when User logoffs


Recommended Posts

I would like that a function of the Script, only then starts if the user logs out. Is it possible, or have I  to write another script ?

<{POST_SNAPBACK}>

if the script runs the whole time, i'm not sure how to do that, besides to have them log out through the script. if it's a script that doesn't have to run all of the time, then i'd just make the function use a command line parameter, and set a logoff script in windows that calls the script with the parameter. that way if the script is called without the parameter or switch ('scriptname.exe /lo' for example) then it would execute normally, but if it is called with that parameter, the log out function runs instead... example

if $CmdLine[0] then 
LogOutFunc()
else
NormalFunc()
endif
Link to comment
Share on other sites

Try using the OnAutoItExit function to execute some code only when your script is terminated. Something like:

#NoTrayIcon

While 1
    Sleep(100)
WEnd

Func OnAutoItExit()
    If (@ExitMethod = 3) or (@ExitMethod = 4) Then; 3=Logoff 4=Shutdown
    ; Code to run before exit...
    EndIf
EndFunc

But beware that you have precious little time to do something before Windows asks the user to end this task.

:whistle: Hmmm... This might be nice as a service using the TCP functions for a sort of "hidden" machine status indicator. Have a server that listens for connecting machines and updates a (possibly web-based) list or a database, and actively marks them as "offline" when they shutdown or reboot... or even differentiate between logoff and shutdown events and tell the server that noone is logged on, or UserX is logged into the machine. My mind is racing on this one... :dance:

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