Jump to content

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
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!
Link to post
Share on other sites
  • 10 years later...

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

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 2021-06-05 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version - Download
Outlook Tools (2019-07-22 - Version - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

ADO - Wiki
WebDriver - Wiki


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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...