Sign in to follow this  
Followers 0
obfuscatedv

Prompting user to save work before something is installed...and more

2 posts in this topic

What I'm trying to do is alert a user pc of an application upgrade.  Its just a simple exe that im storing on the users c: drive.  The user needs to close excel before it can run.  I have tried creating a small gui that allows them to postpone for up to 20 minutes, etc and got down to checking if the process exists, and apparently the function before it doesnt work. So im a bit stuck. 

#RequireAdmin
#NoTrayIcon


Global $intCount = 0
Global $intCount1 = 0


; Alert users of upgrade
Func _DelayedInstall
    $intRemain = 3 - $intCount1
    $guiMain = GUICreate("Upgrade", 350, 150, -1, -1, -1)
    GUICtrlCreateLabel("An add-in update is available. Please close Excel and click install when you are ready.", 25, 20, 310, 60)
    GUICtrlCreateLabel("NOTE:  Clicking the 'X' will cause the install to postpone for 20 minutes", 25, 55, 310, 20)
    $objButtonCont = GUICtrlCreateButton("Install", 82, 90, 70, 20)
    $objButtonDelay = GUICtrlCreateButton("Postpone", 197, 90, 70, 20)
    GUICtrlCreateLabel("You may delay this install for 20 minutes, up to " & $intRemain & " more times.", 40, 125, 310, 20)

; If install postponed 3 times, no longer option
    If $intCount = 3 Then
        GUICtrlSetState($objButtonDelay, $guiDisable)
    EndIf

GUISetState(@SW_ENABLE)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $objButtonCont ; restart if they hit restart
            GUISetState(@SW_HIDE)
        Case $guiEventClose ; proceed with install if they close message box without selecting option
            GUISetState(@SW_HIDE)
            $intCount1 += 1
            Sleep(600000)
            _DelayedInstall()
        Case $objButtonDelay ; they delayed reboot - allows them to save open work in Excel
            GUISetState(@SW_HIDE)
            $intCount1 += 1
            Sleep(600000)
            _DelayedInstall()
            Return
        EndSwitch
    WEnd
EndFunc

; Check for any open occurrences of excel
If ProcessExists("EXCEL.EXE") Then
    MsgBox("0", "", "You are receiving an add-in update and Excel is open.  Please save Excel worksheets and close.  If this dialog box is closed before closing Excel, Excel will be closed automatically.")
Else
EndIf

Share this post


Link to post
Share on other sites



Solved, nevermind.

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  
Followers 0