Jump to content
Sign in to follow this  
stev379

Sleep causes failure with SMS

Recommended Posts

I have a script GUI that has a reboot button and some text to notify users that updates have been run. We want the script to wait 10 minutes before popping the GUI. Does anyone know why we would get a "Bad environment" message when running the GUI with the sleep command in place when pushed with SMS? If we just click the .exe and run it locally there is no problem. If we push with SMS without the timer, it works fine as well.

Thanks for any help or suggestions.

#include <Constants.au3>
#include <GUIConstants.au3>


AutoItSetOption ( "TrayIconHide", 1 )

Sleep(600000)
$Main = GUICreate("Attention NETWORK users:", 480, 300,-1,-1,$WS_DLGFRAME)

GUICtrlCreateLabel ( "Attention NETWORK users:", 85, 15, 300, 33)
GUICtrlSetBKColor(-1,0xcc343e)  ;For color definitions check:   http://www.houseof3d.com/pete/applets/tools/colors/   
GUICtrlSetFont(-1, 20, 400, 4, "Arial Bold")

GUICtrlCreateLabel("In a continuing effort to maintain stable and secure desktop systems, the IT department at NETWORK has installed" _ 
                    & "several patches.  Please restart your " & @CRLF & "computer at your earliest convenience." & @CRLF & @CRLF _
                    & "Thank You," & @CRLF _
                    & "NETWORK Network Administration", 20, 70, 470, 140)
GUICtrlSetFont(-1, 10, 400, "", "Arial")

$btn_Rbt = GUICtrlCreateButton("Reboot now", 55, 200, 75, 25)
GUICtrlSetTip(-1, "Did you save your open files?")
GUICtrlCreateLabel ("Make sure to save any open files before rebooting.", 35, 230, 130, 100)


$btn_RbtLTR = GUICtrlCreateButton("Reboot later", 310, 200, 75, 25)
GUICtrlSetTip(-1, "Click here to reboot later.")

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Select
        
    Case $msg = $btn_RbtLTR
        Exitloop
        
    Case $msg = $btn_Rbt
        $Rbt_NOW = Msgbox(19, "Rebooting", "  About to reboot computer, did you save your work?" & @CRLF _ 
                           & "  Click OK to reboot now.")
        If $Rbt_NOW = 2 Then 
            Exit
        ElseIf $Rbt_NOW = 6 Then 
            Shutdown (2)
        EndIf
        
    EndSelect       
    
WEnd

Share this post


Link to post
Share on other sites

Add a MsgBox(0, "Debug". @UserName) inyour script for debugging and I think you'll see different results for the test run vs. when distrbuted by SMS; I'm guessing SMS runs as System vs. the interactive user. Running as system might be part of the issue.

I don't know anything about SMS, but is it possible that the SMS "session" on the worstation machine is not waiting for the AutoIt script process to end before it disconnects, leaving the script process orphaned with no resources, desktop, etc?


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...