Jump to content

Delay shutdown - Win7


Recommended Posts

Good day. I'm scripting Photoshop install. After the install is done, Photoshop may call for a system reboot. Problem is - there is still a bunch of stuff I'd like to do before that. So I need a UDF that would delay restart until the script finishes, or any advice on how to do it will work just as well. Tried OnAutoItExitRegister, but it delays reboot for XP only.

I've searched the forum, but failed to find a really reliable UDF that'd work on Win7. I could have easily overlooked, I'm relatively new, thats why I'm asking for help. Thanks in advance.

Link to comment
Share on other sites

If you catch it in time you could use the dos command -->> shutdown -a (thought this was it???)

http://pcsupport.about.com/od/commandlinereference/p/shutdown-command.htm

EDIT - not -s but -a, still looking, thought -a was abort

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

You said photoshop is being installed - is there any window that pops up after it is complete and says that it is restarting - if you catch that window, then you can run that command?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Hm... No, no popup. Upon clicking "Finish", it closes the window and goes into restart. Could probably attach command by "WinWaitClose", supposedly by the time window closes, the command is already sent, I just can't be sure about that. Would thoroughly test it, but the damn thing installs/uninstalls for 20 minutes for me. So there is no real way to delay the shutdown until the script is done? At all?

Link to comment
Share on other sites

If, right after you press finish, you use the command shutdown -a -->> it should work?

My thought was that you were using AutoIt to install the application, right after you press the finish button, try the command and see what happens?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

A few methods here for detecting the shutdown, the easiest is that application windows receive a WM_QUERYENDSESSION message, so if you have a GUI then just use GUIRegisterMsg.

To prevent the shutdown automatically occuring, you can just return false from WM_QUERYENDSESSION. That causes the screen to dim and gives the user the option to terminate the process (like when you try and shutdown and there are non-responsive programs).

Better would be to use the ShutdownBlockReasonCreate function.

Link to comment
Share on other sites

@ nitekram

Yes, I was thinking the same thing, but I don't know how reliable that would be: after the window closes, both - Photoshop and my script would pass shutdown/abort shutdown command. What if my script passes "abort" BEFORE Photoshop passes "shutdown"? :) Theoretically it does that upon clicking "Finish" button, but practically... who knows. That's the general reason why I was looking for something more reliable.

@ Mat

Thanks! No, no GUI, but you pointed me in the right direction.

Edited by supraspecies
Link to comment
Share on other sites

Sorry for a new post, couple of days have passed. Anyone has an idea why doesn't this work?

OnAutoItExitRegister("shut")

***My Script***

Func shut()

Run(@ComSpec & " /c shutdown.exe -a")

EndFunc

When Windows was shutting down, the script was running, so when Windows called it to exit, it was supposed to run this function. And yet no go. Any ideas why?

EDIT: Tried to abort the shutdown in progress with a BAT, got "The action has failed to initialize properly". Not a very reliable command, is it...

Edited by supraspecies
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...