vvb Posted January 21, 2013 Share Posted January 21, 2013 (edited) 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 May 9, 2013 by vvb I'll be AutoIting my entire system soon. Link to comment Share on other sites More sharing options...
JohnOne Posted January 21, 2013 Share Posted January 21, 2013 Could be a bug, although I don't see a reason to have 1 and 2 together. Does it work without second (undocumented) param? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted January 21, 2013 Share Posted January 21, 2013 (edited) Try one of these codes for second parameter, or leave it out.EDIT: It is not a string. Edited January 21, 2013 by JohnOne vvb 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
vvb Posted January 21, 2013 Author Share Posted January 21, 2013 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. Link to comment Share on other sites More sharing options...
vvb Posted January 21, 2013 Author Share Posted January 21, 2013 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. Link to comment Share on other sites More sharing options...
Mat Posted January 23, 2013 Share Posted January 23, 2013 (edited) 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 January 23, 2013 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
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