So I was looking at the forums on a script that can do this, but I couldn't really get anything to work.
(I'm on Windows 10 Home)
Is there any way I can do that with just AHK or is it not possible?
Warn on Shutdown and Restart? Topic is solved
Warn on Shutdown and Restart?
Last edited by GenericEntity on 01 Dec 2017, 18:40, edited 1 time in total.
Re: Stop all Shutdown, Restart, Sleep, and Hibernate attempts?
This should help some, although I'm not sure if it's called for standby:
Code: Select all
WM_QUERYENDSESSION(wParam, lParam){
static init:=OnMessage(0x11, "WM_QUERYENDSESSION")
, i:=DllCall("kernel32.dll\SetProcessShutdownParameters", UInt, 0x3FF, UInt, 0) ;First in shutdown priority
Return 0 ;Don't allow end session
}
Re: Stop all Shutdown, Restart, Sleep, and Hibernate attempts?
I ran the script and shut my computer down, but it didn't stop it from shutting down.
Re: Stop all Shutdown, Restart, Sleep, and Hibernate attempts? Topic is solved
NOTE: This does not work on Windows XP and later due to security changes.
Re: Stop all Shutdown, Restart, Sleep, and Hibernate attempts?
Can you elaborate? For me is prevents shutdown on W7 and W10, although "After five seconds, the system displays information about the applications that are preventing shutdown and allows the user to terminate them." So although it intercepts the shutdown, the user has final control on how to proceed. I just use it as a warning in case a USB stick is still plugged in during shutdown of PC's that are not mine.
For me, it's included in a larger script and haven't used it on its own, but a comment on MSDN states:
For me, it's included in a larger script and haven't used it on its own, but a comment on MSDN states:
So perhaps creating a window outside the visible desktop will help (or at least open AHK's main window during testing).For Vista and later, it appears that WM_QUERYENDSESSION is not sent to windows that are not visible. This is an incredibly bad idea, but the least you could do is document the fact.
Re: Stop all Shutdown, Restart, Sleep, and Hibernate attempts?
Currently, the script I tried had no effect whatsoever.
I will try your workaround, but what do you mean by "visible desktop"?
I will try your workaround, but what do you mean by "visible desktop"?
Re: Stop all Shutdown, Restart, Sleep, and Hibernate attempts?
For example moving the window to the position (-10000;-10000), so you don't see it anymore even though its not 'hidden'.
Re: Stop all Shutdown, Restart, Sleep, and Hibernate attempts?
Ah so outside of the rendered desktop
Re: Stop all Shutdown, Restart, Sleep, and Hibernate attempts?
Code: Select all
Gui, New, +Owner, GUI
Gui, Show, x-10000 y-10000, GUI
WM_QUERYENDSESSION(wParam, lParam){
static init:=OnMessage(0x11, "WM_QUERYENDSESSION")
, i:=DllCall("kernel32.dll\SetProcessShutdownParameters", UInt, 0x3FF, UInt, 0) ;First in shutdown priority
Return 0 ;Don't allow end session
}
Re: Warn on Shutdown and Restart?
Updated title.