Jump to content
Sign in to follow this  
Danp2

Perform cleanup @ logoff / shutdown

Recommended Posts

I need to perform some actions before my script exits, and I am having a difficult time handling a system shutdown or logoff request. Using the latest version of Autoit, I have tried:

  • OnAutoItExit
  • GUIRegisterMsg for either WM_QUERYENDSESSION or WM_ENDSESSION
to no avail.

I've searched the forums and found instances where others were having the same difficulties. Does anyone have a working example?

Dan

Share this post


Link to post
Share on other sites

I need to perform some actions before my script exits, and I am having a difficult time handling a system shutdown or logoff request. Using the latest version of Autoit, I have tried:

  • OnAutoItExit
  • GUIRegisterMsg for either WM_QUERYENDSESSION or WM_ENDSESSION
to no avail.

I've searched the forums and found instances where others were having the same difficulties. Does anyone have a working example?

Dan

try this: http://www.autoitscript.com/forum/index.ph...mp;#entry399602

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Hi Kurt,

I've already tried the following, which was based on the post you referenced:

$WM_QUERYENDSESSION = 0x0011

GUICreate("ShutDownNotificationGui")
GUIRegisterMsg($WM_QUERYENDSESSION, "_ShutdownInitiated")
GUISetSTate(@SW_HIDE)

Global $ShutdownInitiated = False

While Not $ShutdownInitiated
    sleep(10)
WEnd

If $ShutdownInitiated Then
    MsgBox(0, "Shutdown", "Shutdown Initiated!", 5)
EndIf
    
Func _ShutdownInitiated($hWndGUI, $MsgID, $WParam, $LParam)
    $ShutdownInitiated = True
    
    Return True
EndFunc

Any other ideas or suggestions?

Thanks, Dan

Share this post


Link to post
Share on other sites

I hope that bumping this topic wont get me into trouble but I am really interested in this, as I have the same problem.


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

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  

×
×
  • Create New...