Jump to content

Countdown to a reboot

Recommended Posts


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,


If $CmdLine[0]>0 then
  $mTime = $CmdLine[1]
  $begin = @Hour & ":" & @min
  $end = @Hour & ":" & @min + $mTime

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)

Until @Hour & ":" & @min > $End

MsgBox(48, "Test2", "Start: " & $begin & " End: " & @hour & ":" & @min,100)
;Shutdown(6) ;Force a reboot

Share this post

Link to post
Share on other sites

$timeInHours = 2
$timeInMilliseconds = $timeInHours * 60 * 60 * 1000 

$t = TimerInit()
While TimerDiff($t) < $timeInMilliseconds
 ;stuff could go here such as a progress meter
 ;  depending on the value of TimerDiff($t)

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post

Link to post
Share on other sites

For $c = 10 to 0 Step -1
   ToolTip('Secs ' & $c)

Share this post

Link to post
Share on other sites


Did you by chance come up with  a solution?? I could really use it for a couple of servers...

Share this post

Link to post
Share on other sites

This thread is over 10 years old!

Anyhow, try this:

#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)
Global $sEndTime = _DateAdd("s", $iSeconds, _NowCalc()), $sDiff

    $sDiff = _DateDiff("s", _NowCalc(), $sEndTime)
    GUICtrlSetData($iInp_Seconds, $sDiff)
    If $sDiff < 1 Then ExitLoop
    Switch GUIGetMsg()
        Case $iBtn_Abort
            ConsoleWrite("Rebooting has been aborted!" & @CRLF)
        Case $iBtn_Now
Until False
ConsoleWrite("Rebooting system..." & @CRLF)


Edited 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
Share on other sites

mbouchard has been offline for 2 years. You do not expect him to answer, do you :huh:

My UDFs and Tutorials:


Active Directory (NEW 2017-04-18 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version - Download - General Help & Support

ADO - Wiki


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


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.