IanN1990 Posted August 19, 2012 Posted August 19, 2012 (edited) When ever my pc shuts own, its always hangs by some application and just looks horrible. It normally comes 2 the case where i need to do a force shutdown. Before i tryed the idea of autoits Exit-Method and then making it do a forced restart. Is there any way for the exit method to tell if the pc is shutting down "in which case do a forced shutdown" or is restarted "in which case do a forced restart"? Edited September 8, 2012 by IanN1990
EKY32 Posted August 19, 2012 Posted August 19, 2012 Maybe you can try to detect the window that tells you some time that you need to force end some processes. Why don't you try to fix the Windows problem? check if it's internal and use the command-line (DOS) typing ( sfc /scannow ) - you might need the Windows Installation Disk if your OS is under Win Vista. Good luck. [font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]
AZJIO Posted August 20, 2012 Posted August 20, 2012 It has no relevance to AutoIt. I use shortcuts on your desktop ("Win + D" - minimizes window). Shut down the computer C:WINDOWSsystem32shutdown.exe -s -t 00 -f Reboot the computer C:WINDOWSsystem32shutdown.exe -r -t 00 -f My other projects or all
EKY32 Posted August 20, 2012 Posted August 20, 2012 Yes that's right, but i think he means he wants an automatic technology? not using shortcuts. It helps anyway. [font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]
IanN1990 Posted August 25, 2012 Author Posted August 25, 2012 @Azjio The shortcuts is a good idea but as Eky32 i want it more automatic. As my script runs 24/7 it would be nice for it to detect what type of shutdown is happening and act accordinly
Bowmore Posted August 26, 2012 Posted August 26, 2012 You need to set up a message handler using GUIRegisterMsg() for WM_QUERYENDSESSIONand then take the appropriate action when windows send the WM_QUERYENDSESSION message prior to shutting down.see MSDN for details http://msdn.microsoft.com/en-us/library/windows/desktop/aa376890(v=vs.85).aspx "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
Manko Posted August 27, 2012 Posted August 27, 2012 (edited) Is there any way for the exit method to tell if the pc is shutting down "in which case do a forced shutdown" or is restarted "in which case do a forced restart"?This is a frequently asked question on the net. And the answer is always no. It is not possible to destinguish between shutdown and restart. It is crazy, but that is the way it is. (Atleast not in any straightforward way... Maybe hook shutdown-API... or other things...)/Manko Edited August 27, 2012 by Manko Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...
IanN1990 Posted August 30, 2012 Author Posted August 30, 2012 Yea searching the forums it seams alot of people ask this similar question with no answer or the answer requires a high level of coding + windows understanding. Maybe some day someone could make a UDF on it, as it would be quite useful
Blue_Drache Posted August 30, 2012 Posted August 30, 2012 (edited) This is a frequently asked question on the net. And the answer is always no. It is not possible to destinguish between shutdown and restart. It is crazy, but that is the way it is. (Atleast not in any straightforward way... Maybe hook shutdown-API... or other things...)/MankoThat's generally because the OS takes care of the difference. It does not matter to the program in the slightest what the OS is doing. All it (the program) was told to do was close. Period. And that's really all it needs to do. The why is moot. Edited August 30, 2012 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
BrewManNH Posted August 30, 2012 Posted August 30, 2012 It seems to be an issue with Windows not telling applications that it's rebooting rather than just shutting down, so a UDF probably wouldn't be easy to accomplish. Look on Stackoverflow.com for how many times this gets asked and the answer is always that it would be very hard to detect if possible at all. 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! 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
Manko Posted September 11, 2012 Posted September 11, 2012 Yea searching the forums it seams alot of people ask this similar question with no answer or the answer requires a high level of coding + windows understanding. Maybe some day someone could make a UDF on it, as it would be quite useful If you really found some examples that can do this, please point the way, because I have not found anything like that. Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...
IanN1990 Posted September 12, 2012 Author Posted September 12, 2012 just incase someone finds this one day and does know the answer but is a ltitle confused the end result would be something like this. If Computer is shuttingdown then Shutdown(17) "16 force if hung and 1 is shutdown) elseif computer is rebooting then shutdown(18) "16 force if hung and 2 is reboot) else do nothing and exit normally endif
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