Jump to content
Sign in to follow this  
vvb

[Solved] Issues with shutdown

Recommended Posts

vvb

Hi All,

I am trying to automate restart/logoff and then logon again on a Windows Server 2003 computer. I have been using Shutdown(6) to force a restart, however, after login on, I get a message popping up stating "The system has restarted after an unplanned shutdown". I have provided a reason for the shutdown as well. It makes no difference between Shutdown(2, "planned restart") and Shutdown(6, "planned restart").

Anyone know what is happening?

BTW, Shutdown(0, "login off") and Shutdown(4, "login off") has the same effect of showing the unplanned shutdown.

Thanks in advance.

Vlad

Edit: From looking at shutdown.exe the reason has to be one of the specified ones. So using the native shutdown.exe /r /t 0 /d p:0:0 does not cause the unplanned shutdown message to appear, however, specifying "p:0:0" for the AutoIt Shutdown function still causes the unplanned shutdown message to appear.

Edited by vvb

I'll be AutoIting my entire system soon.

Share this post


Link to post
Share on other sites
vvb

Just tried without the secon parameter with Shutdown(6) and Shutdown(4) and both works. Hmm, you are right, there is a but with Shutdown in the way it handles the second optional parameter.


I'll be AutoIting my entire system soon.

Share this post


Link to post
Share on other sites
vvb

Just tried with 0x80000000 as the second parameter for both logout and restart and no more unplanned messages popping up. The link to that page needs to be added to the Shutdown help page.

Cheers John.


I'll be AutoIting my entire system soon.

Share this post


Link to post
Share on other sites
Mat

John/Vlad,

you are better off calling the winapi function ExitWindowsEx directly. The shutdown function is more complicated than just passing the flags.

Might be worth noting that it is a planned restart by default anyway.

Edited by Mat

Share this post


Link to post
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
Sign in to follow this  

×