Jump to content

Msgbox sleep issue

Recommended Posts


I have created a program that run list of actions upon loading up into a user account each user account could have it own start up list.

I have create a sleep,n command(n= seconds to sleep) which the user and use to slow the process down if needed. I have deployed this script to over 2000 machine and all except a random 6-10 machines on of the 2000 machine behave perfectly. However 6-10 machines every night get stuck on the on the msgbox which controls the the sleep cycle. As soon as to click the ok button the script continues to process.

Has anyone expeience problem with using the sleep function built into the msgbox command?

Here my code


;Include some additional autoit funcutions into my script
#Include <process.au3>

;Declaring some varibles
Dim $errormessage,$admin,$x

;Read Values from ini file
$SynchTime = IniRead (@ScriptDir & "\load.ini","General","SynchTime","No")
$SynchTimeComputer = IniRead (@ScriptDir & "\load.ini","General","SynchTimeComputer","")
$WaitforTimeServer = IniRead (@ScriptDir & "\load.ini","General","WaitforTimeServer","No")
$MapADriveToComp = IniRead (@ScriptDir & "\load.ini","General","MapADriveToComp","No")
$MapPath = IniRead (@ScriptDir & "\load.ini","General","MapPath","No")
$DeleteTempDir = IniRead (@ScriptDir & "\load.ini","General","SynchTime","No")
$DeletecustomDir = IniRead (@ScriptDir & "\load.ini","General","SynchTime","No")
$DeleteCustomDirPath = IniRead (@ScriptDir & "\load.ini","General","SynchTime","")
$RunState = IniRead (@ScriptDir & "\load.ini","General","RunState","@SW_HIDE")

    IF Not FileExists (@ScriptDir & "\load.ini") THEN Exit
    IF $WaitforTimeServer = "Yes" THEN
            SplashTextOn ("","Waiting For " & $SynchTimeComputer &@CRLF&@CRLF& "Press Esc to skip",200,100,-1,-1,1,"",16)
                $p = Ping ($SynchTimeComputer)
                    IF $X = 1 THEN Exitloop
        Until $p > "0"

    IF $MapADriveToComp = "Yes" THEN
        SplashTextOn ("","Mapping drive" ,200,100,-1,-1,1,"",16)
            Run ($MapPath,"",@SW_HIDE)

    IF $SynchTime = "Yes" THEN _Rundos ("net time \\" & $SynchTimeComputer & " /set /y")
    IF $DeleteTempDir = "Yes" THEN FileDelete ("c:\temp\*.*")
    IF $DeletecustomDir = "Yes" THEN FileDelete ($DeleteCustomDirPath)

    $DoOnce = IniReadSection (@ScriptDir & "\load.ini","DoOnce")
    IF $DoOnce = 1 Then
        IniDelete (@ScriptDir & "\load.ini","DoOnce")
Func Action($Section)

    $user = IniReadSection (@ScriptDir & "\load.ini",$Section)
    IF @error=1 THEN Exit
        For $n = 1 to $user [0] [0]
            $z = $user [$n] [1]
            $s = StringSplit ($z,",")
                IF $s[1] = "sleep" THEN
                    msgbox (64,"Pausing for "& $s[2] & " seconds","Click OK to abort the pause",$s[2])
                ELSEIF $s[1] == "<ChangeName>" THEN
                ELSEIF StringInStr($z,"Chkdsk") THEN
                    Run (@ComSpec & " /c " & $z,"",$RunState)
                ELSEIF $z == "<Reboot>" THEN
                    IniDelete (@ScriptDir & "\load.ini","DoOnce")
                    Run ($z,"",$RunState)
                    IF @error THEN $errormessage = MsgBox(54,"Error unable to run command", "Unable to run " & $s[1])
                    IF $errormessage = 2 THEN EXIT
                    IF $errormessage = 10 THEN $n = $n -1 

Func ChangeName($ComputerName)
    IF $ComputerName == "*" Then $ComputerName = "TmpName" & Random (00000000,99999999,1)

    SplashTextOn ( "", ".....Please Wait..... Changing ComputerName",@DesktopWidth,140,-1,@DesktopHeight-140,1,"",18)
            $strComputer = "."
            $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
            $colComputers = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
                For $objComputer in $colComputers

Func Endloop()
    $x = 1
Link to comment
Share on other sites

  • Moderators


My instant thought is that the $s[2] value you use to set the timeout is coming up as 0, which will give you a MsgBox which waits for a click. If it were undefined you would get the same result.

Try adding a check to the code to see if that is the case - and if so, then set the value to something reasonable.

Top Tip: It is always a good idea to check that you have valid values after a StringSplit. :)

I hope that helps. :idea:


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to comment
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...