mbouchard Posted October 25, 2004 Share Posted October 25, 2004 I am working on a reboot script that can be called from another script with the time to wait till reboot. I think that I have a basic script working but think that I know of one point of failure. I am using @hour @ min and to get the start time and then using @hour@min+my commandline to get the end time. I then compare the two. My problem pops up if the start time is just before the bottom of the hour and the command line would push the end time over 60. Also, I am trying to figure out how to have a countdown in my message box so that the user will know how much time they have left before a reboot will happen. I have thought about using a progress bar but lose the ability to give a way to reboot immediately. Any ideas would be apprciated, Mike If $CmdLine[0]>0 then $mTime = $CmdLine[1] $begin = @Hour & ":" & @min $end = @Hour & ":" & @min + $mTime EndIf MsgBox(48, "Test", "To complete the install, your computer will be rebooted in " & $mTime & " minute(s) at " & $end & "." & @CR & @CR & "Clicking the OK button below will cause the computer to reboot now." & @CR & "The reboot is automatic and there will be no further warning messages. ",$mTime*60) Do Sleep(2000) Until @Hour & ":" & @min > $End MsgBox(48, "Test2", "Start: " & $begin & " End: " & @hour & ":" & @min,100) ;Shutdown(6) ;Force a reboot Link to comment Share on other sites More sharing options...
CyberSlug Posted October 25, 2004 Share Posted October 25, 2004 $timeInHours = 2 $timeInMilliseconds = $timeInHours * 60 * 60 * 1000 $t = TimerInit() While TimerDiff($t) < $timeInMilliseconds sleep(1000) ;stuff could go here such as a progress meter ; depending on the value of TimerDiff($t) WEnd Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
ezzetabi Posted October 25, 2004 Share Posted October 25, 2004 For $c = 10 to 0 Step -1 ToolTip('Secs ' & $c) Next Shutdown(9+4) Link to comment Share on other sites More sharing options...
charlesg7 Posted May 28, 2015 Share Posted May 28, 2015 mbouchardDid you by chance come up with a solution?? I could really use it for a couple of servers... Link to comment Share on other sites More sharing options...
UEZ Posted May 28, 2015 Share Posted May 28, 2015 (edited) This thread is over 10 years old!Anyhow, try this:#AutoIt3Wrapper_Change2CUI=y #include <Date.au3> #include <EditConstants.au3> If Not $CmdLine[0] Then Exit ConsoleWrite(@CRLF & "Usage: RebootWrapper.exe <seconds>" & @CRLF & @CRLF) Global $iSeconds = Int($CmdLine[1]) Global Const $hGUI = GUICreate("RebootWrapper", 320, 200) Global Const $iLabel_Text = GUICtrlCreateLabel("System will be rebooted in: ", 10, 50, 190, 20) GUICtrlSetFont(-1, 12) GUICtrlSetBkColor(-1, 0xFF0000) Global Const $iInp_Seconds = GUICtrlCreateInput("", 210, 50, 30, 20, BitOR($ES_NUMBER, $ES_READONLY)) Global Const $iBtn_Abort = GUICtrlCreateButton("Abort", 10, 120, 100, 50) Global Const $iBtn_Now = GUICtrlCreateButton("Reboot now", 200, 120, 100, 50) GUISetState() Global $sEndTime = _DateAdd("s", $iSeconds, _NowCalc()), $sDiff Do $sDiff = _DateDiff("s", _NowCalc(), $sEndTime) GUICtrlSetData($iInp_Seconds, $sDiff) If $sDiff < 1 Then ExitLoop Switch GUIGetMsg() Case $iBtn_Abort GUIDelete() ConsoleWrite("Rebooting has been aborted!" & @CRLF) Exit Case $iBtn_Now ExitLoop EndSwitch Until False GUIDelete() ConsoleWrite("Rebooting system..." & @CRLF) Edited May 28, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
water Posted May 28, 2015 Share Posted May 28, 2015 mbouchard has been offline for 2 years. You do not expect him to answer, do you My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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