j0kky Posted April 9, 2014 Posted April 9, 2014 (edited) Hi, I'm trying to abort a started shutdown via start>>"Shut Down" on Windows 7 with but I can't find a solution. It's simple to abort a timed-out shutdown thanks to "shutdown -a" or "AbortSystemShutdown" because (I think) that function only interrupt the timeout. I've written this simple script (looking to previous posts about this argument): it is an idle loop that waits for WM_QUERYENDSESSION message and then it creates a block reason to stop the shutdown process. But an endless serie of error "the application was unable to start correctly (0xc0000142)" labelled "shutdown.exe" is shown and the shutdown is only paused, not aborted. #Include <ButtonConstants.au3> #Include <GUIConstantsEx.au3> #Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) Global $hForm, $Msg, $Button, $Check, $var = False $hForm = GUICreate('MyGUI', 200, 200) GUIRegisterMsg(0x0011, 'WM_QUERYENDSESSION') GUISetState(@SW_HIDE) _WinAPI_SetProcessShutdownParameters(0x03FF) While 1 $Msg = GUIGetMsg() _WinAPI_ShutdownBlockReasonCreate($hForm, 'something') If $var = True Then Run("C:\windows\system32\shutdown.exe -a") WEnd Func WM_QUERYENDSESSION($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hForm $var = True Return 0 EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_QUERYENDSESSION I'm beginning to think that what I want to do is impossible Thanks to all. Edited April 9, 2014 by j0kky Reveal hidden contents Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs
JohnOne Posted April 9, 2014 Posted April 9, 2014 Out of curiosity, Why? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
j0kky Posted April 9, 2014 Author Posted April 9, 2014 (edited) My family use my laptop and then they use to shutdown pc causing problems to execution of Vuze, BOINC, and other programs... So I would like to intercept ShutDown and convert it to Sleep. Edited April 9, 2014 by j0kky Reveal hidden contents Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs
JohnOne Posted April 9, 2014 Posted April 9, 2014 I'm quite sure Sleep will also stop those programs from running. Can you not choose what option are in the shut down menu? I'm sure I've seen them while using a lap top in control panel. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
j0kky Posted April 10, 2014 Author Posted April 10, 2014 Thank you for the answer! With Sleep you can resume works where you have suspend them: Quote [...]sleep puts your work and settings in memory and draws a small amount of power[...] From: http://windows.microsoft.com/ I've solved changing the default ShutDown button on start menu with Sleep but it is a sort of palliative. Is there a way to automatically abort the shutdown with a script? Reveal hidden contents Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs
JohnOne Posted April 10, 2014 Posted April 10, 2014 (edited) Probably, but I imagine it's a rather advanced and complicated endeavor.Probably have more chance searching web for such a function before someone here takes it on.Ok it's what you want. but if it were me it would not be worth the trouble, because I'd simply lock my laptop if other users did not respect my wishes not to shut it down. Edited April 10, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
JohnOne Posted April 10, 2014 Posted April 10, 2014 To tackle the issue in a sensible way. Make accounts for other users and set those accounts unable to shut it down.Here is an article how to do it. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
j0kky Posted April 11, 2014 Author Posted April 11, 2014 (edited) This is a good solution... but not for me: I keep the laptop always on, logged in my account. I'm not worried about the programming endeavor but I've gone over shutdown references on MSDN and it seems there is no functions good for this purpose. Do you have any ideas? Edited April 11, 2014 by j0kky Reveal hidden contents Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs
Palestinian Posted April 11, 2014 Posted April 11, 2014 Install HandyCafe, you can't shut down a computer if the client is running
j0kky Posted April 12, 2014 Author Posted April 12, 2014 Sorry but it is definetly not what I'm looking for! Reveal hidden contents Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs
Bert Posted April 12, 2014 Posted April 12, 2014 So, you want your laptop available on demand, applications that are running to stay running, and keep your family from shutting down the laptop. Why not just get them their own laptop and your problem is solved permanently? They can shut down to their heart's content, your stuff is not messed with at all and you don't need to worry about "custom" settings on your laptop. The Vollatran project My blog: http://www.vollysinterestingshit.com/
j0kky Posted April 12, 2014 Author Posted April 12, 2014 ahahah, a bit too expensive solution Joking apart, I've red these "best practice" form MSDN: Quote Applications should not block shutdown. Respond to WM_QUERYENDSESSION as quickly as possible and postpone cleanup activities until processing the WM_ENDSESSION message. Applications that must block shutdown should use the new ShutdownBlockReasonCreate function to register a string that explains the reason to the user. The user can decide whether to continue or cancel shutdown. Applications cannot rely on being able to block shutdown. They don't tell us we can't do what I want, they tell us we just shouldn't... However they don't provide a direct function to abort the started shutdown Reveal hidden contents Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs
Bert Posted April 12, 2014 Posted April 12, 2014 How about this - setup separate profiles. The other profiles have the shutdown option revoked. Your profile is password protected. This is NO money to do, they don't mess with anything you have running on your profile and you don't mess with anything they have. Nice, simple, free, and no scripting needed. The Vollatran project My blog: http://www.vollysinterestingshit.com/
Unc3nZureD Posted April 12, 2014 Posted April 12, 2014 (edited) A small question: Why do you loop _WinAPI_ShutdownBlockReasonCreate($hForm, 'something') a gazillion times? It needs to be called once only. Edited April 12, 2014 by Unc3nZureD
j0kky Posted April 13, 2014 Author Posted April 13, 2014 @Unc3nZureD: You're right, I've included it in the called function. @MBALZESHARI: I have Windows 7 home premium and it hasn't Group Policy editor (Local Security Police snap-in) Reveal hidden contents Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs
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