speedy6 Posted March 20, 2007 Share Posted March 20, 2007 Is it possible in autoit to catch a shutown command from windows: I want to start a scan when the user wants to shutdown the pc, after the scan i will shutdown the computer myself... Is this possible? Thanks. Link to comment Share on other sites More sharing options...
dabus Posted March 20, 2007 Share Posted March 20, 2007 (edited) 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. Edited March 20, 2007 by dabus Link to comment Share on other sites More sharing options...
Somerset Posted March 20, 2007 Share Posted March 20, 2007 please just askingly. remove that code.... Link to comment Share on other sites More sharing options...
Valik Posted March 20, 2007 Share Posted March 20, 2007 Assuming that script actually works, there's really nothing wrong with it as it's just using the Windows API. Link to comment Share on other sites More sharing options...
Somerset Posted March 20, 2007 Share Posted March 20, 2007 alrighty just on the side of caution...because on slow shutting down systems this can be used for not so nice behavior is all. Link to comment Share on other sites More sharing options...
dabus Posted March 20, 2007 Share Posted March 20, 2007 (edited) Hmm, I found it here, so I assume it wasn't that bad and will not be, but if the mods want to, I have no problem if they remove it.Here is the original if you want to delete both...http://www.autoitscript.com/forum/index.php?showtopic=38292 Edited March 20, 2007 by dabus Link to comment Share on other sites More sharing options...
Valik Posted March 20, 2007 Share Posted March 20, 2007 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 More sharing options...
speedy6 Posted March 22, 2007 Author Share Posted March 22, 2007 What is the matter? It a nice script and it works fine but with vista... had anyone a solution for that.... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now