Jump to content

No shutown


Recommended Posts

You may test this, I found that here, but never used it since you can set permissions via mmc.

Opt("TrayIconHide", 1)

$WM_QUERYENDSESSION = 0x0011
GUIRegisterMsg($WM_QUERYENDSESSION, "Cancel_Shutdown")
GUICreate("PreventShutdownGUI")
GUISetSTate(@SW_HIDE)
Global $b_ShutdownInitiated = False


While 1
    If $b_ShutdownInitiated = True then
        ;Do stuff here
        ;do some more stuff here
        ;DoTheShutDownStuff();maybe do some more stuff here 
        ;Shutdown();Maybe you want to shutdown the computer when done
        Exit;otherwise, you just exit this script
    EndIf
    sleep(10)
WEnd

Func Cancel_Shutdown($hWndGUI, $MsgID, $WParam, $LParam)
;~     run(@ScriptDir & "\killpgm.exe")
    $b_ShutdownInitiated = True
    Return False
EndFunc

As far as I remind, it just disables the shutdown-graphics, and since windows waits for them to appear, it wait as long as the script is running. :whistle:

Edited by dabus
Link to comment
Share on other sites

It's actually not such a big deal. If you specify the "force" flag during shutdown, WM_QUERYENDSESSION and WM_ENDSESSION aren't even sent. I'm not sure what flags the shell uses when you invoke shut down that way, but at worst, a user might have to use "shutdown -f" to ensure a forced shutdown.

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