Darkinspiration Posted December 21, 2006 Posted December 21, 2006 (edited) Okay this is the situation: i need to execute some actions when windows 98 is shutting down. Now the last autoit beta provide me with the mean to intercept a system shutdown that will close my script with onautoitexit. But i whant to insure that my commands are carried out and not closed by the system. So how can i use autoit to abort a windows 98 system shutdown in order to carry a set of actions? Edited December 21, 2006 by Darkinspiration
Xand3r Posted December 22, 2006 Posted December 22, 2006 Darkinspiration said: Okay this is the situation: i need to execute some actions when windows 98 is shutting down. Now the last autoit beta provide me with the mean to intercept a system shutdown that will close my script with onautoitexit.But i whant to insure that my commands are carried out and not closed by the system. So how can i use autoit to abort a windows 98 system shutdown in order to carry a set of actions?TRY $msg="shutdown -a"Run(@ComSpec & " /c " & $msg, "", @SW_HIDE) Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro
Darkinspiration Posted December 22, 2006 Author Posted December 22, 2006 alexmadman said: TRY $msg="shutdown -a"Run(@ComSpec & " /c " & $msg, "", @SW_HIDE)somebody didn't read the windows 98 bit... shutdown.exe is only available on windows xp
eynstyne Posted December 24, 2006 Posted December 24, 2006 This might only be for networked machines, and maybe newer versions of windows... Dllcall("advapi32.dll","int","AbortSystemShutdownA","str","\\Computername") F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]
The Kandie Man Posted December 24, 2006 Posted December 24, 2006 (edited) This should abort any non-forced shutdown you throw at it: $WM_QUERYENDSESSION = 0x0011 GUIRegisterMsg($WM_QUERYENDSESSION, "Cancel_Shutdown") GUICreate("PreventShutdownGUI") GUISetSTate(@SW_HIDE) While 1 sleep(10) WEnd Func Cancel_Shutdown($hWndGUI, $MsgID, $WParam, $LParam) Return False EndFunc Note: I haven't tested it on windows 98. Pretty sure it should still work. Works on win2k and XP. Edited December 24, 2006 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire
Darkinspiration Posted January 3, 2007 Author Posted January 3, 2007 (edited) Dllcall("advapi32.dll","int","AbortSystemShutdownA","str","\\Computername") This dosen't appear to be working on windows 98 but thanks for trying $WM_QUERYENDSESSION = 0x0011 GUIRegisterMsg($WM_QUERYENDSESSION, "Cancel_Shutdown") GUICreate("PreventShutdownGUI") GUISetSTate(@SW_HIDE) While 1 sleep(10) WEnd Func Cancel_Shutdown($hWndGUI, $MsgID, $WParam, $LParam) Return False EndFunc This however is working perfectly. It's not very flexible however. It's difficult to insert code because Cancel_Shutdown mustreturn false and i doubt i can use it's param to detect it it's ben run. The only way i see of using this is by adding a run() to the function Cancel_Shutdown. Opt("TrayIconHide", 1) $WM_QUERYENDSESSION = 0x0011 GUIRegisterMsg($WM_QUERYENDSESSION, "Cancel_Shutdown") GUICreate("PreventShutdownGUI") GUISetSTate(@SW_HIDE) While 1 if ProcessExists("killpgm.exe") then Exit endif sleep(10) WEnd Func Cancel_Shutdown($hWndGUI, $MsgID, $WParam, $LParam) run(@ScriptDir & "\killpgm.exe") Return False EndFunc Edited January 3, 2007 by Darkinspiration
The Kandie Man Posted January 3, 2007 Posted January 3, 2007 You can do stuff like this: 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 "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire
Darkinspiration Posted January 3, 2007 Author Posted January 3, 2007 Yeah, i just realised that i could declare variables as global.... Dumb me...
SoulA Posted February 9, 2009 Posted February 9, 2009 The Kandie Man said: You can do stuff like this: 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 This code works great on Windows XP but doesn't seem to work on Vista machines. Anyone have any idea how I can get something similar to work on Vista?
kercyr Posted February 24, 2016 Posted February 24, 2016 Hello, Did you find a solution for Windows Seven 64 bits, to intercept the shutdown ? Regards,
BrewManNH Posted February 24, 2016 Posted February 24, 2016 You do realize that this post hasn't had a response in it in over 7 years right? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! Reveal hidden contents I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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