nathancook Posted December 16, 2010 Share Posted December 16, 2010 Hi, I am getting through creating an application to upgrade our windows xp images while they are off the network. The idea is that the desktop engineer logs on as an admin and starts the exe from a USB drive or DVD. The script checks who they are logged on as and exits if it's not the correct user, it then carries on if all is well. The problem I have is that the progress bar doesn't work the way I want. I'd like the progress bar to either show progress all the way through the script, or just when the script starts and then stops an install job. It's all a bit rough at the moment as I'd like to get the progress bar working first the do some testing around the application installs. Any help appreciated. Here's the script: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: Nathan Cook Script Function: Used to upgrade desktop applications while offline. #ce ---------------------------------------------------------------------------- #AutoIt3Wrapper_Res_Description=Image Upgrade for Windows XP #AutoIt3Wrapper_Res_Fileversion=0.1 ;Progress Bar ProcessSetPriority(@ScriptName, 4) ProgressOn("Image Upgrade for Windows XP", "Overall Program Completion... ", "0 percent", 20, 20, 16) ;Warning message MsgBox(262192, "Image Upgrade for Windows XP", "This will automatically start in 20 seconds! " & _ @CRLF & @CRLF & "** PLEASE CLOSE ALL PROGRAMS **", 20) ;User check If @UserName <> "SOEImage" Then if MsgBox(262192, "Logging off", "You must be logged on as SOEImage logging off in 10 seconds" & _ @CRLF & @CRLF & "Press *OK* to cancel.", 10) = -1 Then Shutdown(20) Exit ;Tray tip TrayTip("Applications", "Installing Applications", 5, 1) Sleep(5000) ;Install Applications ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") ;Tray tip TrayTip("Hotfixes", "Installing Hotfixes.", 5, 1) Sleep(5000) ;Install Hotfixes ShellExecuteWait("\hotfixes\myfile.exe /passive /norestart /nobackup") ShellExecuteWait("\hotfixes\myfile.exe /passive /norestart /nobackup") ShellExecuteWait("\hotfixes\myfile.exe /passive /norestart /nobackup") ShellExecuteWait("\hotfixes\myfile.exe /passive /norestart /nobackup") ProgressSet(100, "... Shutting System Down ") ProgressOff() ;Shutdown message If MsgBox(262192, "Upgrade Complete Restart Initiated", "Computer will automatically Restart in 30 seconds!" & _ @CRLF & @CRLF & "Press *OK* to Cancel.", 30) = -2 Then Shutdown(9) EndIf Link to comment Share on other sites More sharing options...
shanet Posted December 16, 2010 Share Posted December 16, 2010 (edited) Nathan, I just want to let you and any others know that I am working on it, but there is quite a lot of changes to be done so just sit tight, I should be done within 10 minutes.shanetEDIT-- We are almost there Edited December 16, 2010 by shanet [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm Link to comment Share on other sites More sharing options...
Realm Posted December 16, 2010 Share Posted December 16, 2010 Hello nathancook,All you need to do is place a ProgressSet() everywhere you need it to change. There really is no automatic way of changing that function.For example:ProgressOn("Image Upgrade for Windows XP", "Overall Program Completion... ", "0 percent", 20, 20, 16) ;Install Applications ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") ProgressSet(25, "... Shutting System Down ") ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") ProgressSet(50, "... Shutting System Down ") ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") ProgressSet(75, "... Shutting System Down ") ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") ProgressSet(100, "... Shutting System Down ") ProgressOff()Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
shanet Posted December 16, 2010 Share Posted December 16, 2010 (edited) @Realm: Hello there! Nathan has also included a label saying x% completed, so this script caters for that as well. Very basic, $percent increases by 12.5 every time it is crossed, then the progress meter reads off $percent and sets itself to that, then the label is deleted and re-created under the same variable name ($infotext) with x being $percent Nathan, here is the completed script: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: Nathan Cook & Shane Thompson Script Function: Used to upgrade desktop applications while offline. #ce ---------------------------------------------------------------------------- #include <GUIConstantsEX.au3> Opt("MustDeclareVars", 1) #AutoIt3Wrapper_Res_Description=Image Upgrade for Windows XP #AutoIt3Wrapper_Res_Fileversion=0.1 Local $winhandle, $percent = 0, $progress, $infotext, $errormsg, $winhandle2 ProcessSetPriority(@ScriptName, 4) $winhandle = GUICreate("Image Upgrade for Windows XP", 300, 100, 65, 40) $infotext = GUICtrlCreateLabel("Overall Program Completion... " & $percent & " percent", 10, 80) $progress = GUICtrlCreateProgress(30, 30, 250) GUISetState() ;Warning message MsgBox(262192, "Image Upgrade for Windows XP", "This will automatically start in 20 seconds! " & _ @CRLF & @CRLF & "** PLEASE CLOSE ALL PROGRAMS **", 20) ;User check If @UserName <> "SOEImage" Then if MsgBox(262192, "Logging off", "You must be logged on as SOEImage logging off in 10 seconds" & _ @CRLF & @CRLF & "Press *OK* to cancel.", 10) = -1 Then Shutdown(20) Exit Else ;Tray tip TrayTip("Applications", "Installing Applications", 5, 1) Sleep(5000) ;Install Applications ;;;Each Application is 12.5% if ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") = 0 Then $errormsg = "Application 1 did not install correctly." EndIf $percent += 12.5 GUICtrlSetData($progress, $percent) GUICtrlDelete($infotext) $infotext = GUICtrlCreateLabel("Overall Program Completion... " & $percent & " percent", 10, 80) if ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") = 0 Then $errormsg = $errormsg & @CRLF & "Application 2 did not install correctly." EndIf $percent += 12.5 GUICtrlSetData($progress, $percent) GUICtrlDelete($infotext) $infotext = GUICtrlCreateLabel("Overall Program Completion... " & $percent & " percent", 10, 80) If ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") = 0 Then $errormsg = $errormsg & @CRLF & "Application 3 did not install correctly." EndIf $percent += 12.5 GUICtrlSetData($progress, $percent) GUICtrlDelete($infotext) $infotext = GUICtrlCreateLabel("Overall Program Completion... " & $percent & " percent", 10, 80) if ShellExecuteWait("\applications\myfile.msi TRANSFORM=SOMETRANSFORM.mst /qn /noreboot") = 0 Then $errormsg = $errormsg & @CRLF & "Application 4 did not install correctly." EndIf $percent += 12.5 GUICtrlSetData($progress, $percent) GUICtrlDelete($infotext) $infotext = GUICtrlCreateLabel("Overall Program Completion... " & $percent & " percent", 10, 80) ;Tray tip TrayTip("Hotfixes", "Installing Hotfixes.", 5, 1) Sleep(5000) ;Install Hotfixes if ShellExecuteWait("\hotfixes\myfile.exe /passive /norestart /nobackup") = 0 Then $errormsg = $errormsg & @CRLF & @CRLF & "Hotfix 1 did not install correctly." EndIf $percent += 12.5 GUICtrlSetData($progress, $percent) GUICtrlDelete($infotext) $infotext = GUICtrlCreateLabel("Overall Program Completion... " & $percent & " percent", 10, 80) If ShellExecuteWait("\hotfixes\myfile.exe /passive /norestart /nobackup") = 0 Then $errormsg = $errormsg & @CRLF & "Hotfix 2 did not install correctly." EndIf $percent += 12.5 GUICtrlSetData($progress, $percent) GUICtrlDelete($infotext) $infotext = GUICtrlCreateLabel("Overall Program Completion... " & $percent & " percent", 10, 80) If ShellExecuteWait("\hotfixes\myfile.exe /passive /norestart /nobackup") = 0 Then $errormsg = $errormsg & @CRLF & "Hotfix 3 did not install correctly." EndIf $percent += 12.5 GUICtrlSetData($progress, $percent) GUICtrlDelete($infotext) $infotext = GUICtrlCreateLabel("Overall Program Completion... " & $percent & " percent", 10, 80) If ShellExecuteWait("\hotfixes\myfile.exe /passive /norestart /nobackup") = 0 Then $errormsg = $errormsg & @CRLF & "Hotfix 4 did not install correctly." EndIf $percent += 12.5 GUICtrlSetData($progress, $percent) GUICtrlDelete($infotext) $infotext = GUICtrlCreateLabel("Overall Program Completion... " & $percent & " percent", 10, 80) $winhandle2 = GUICreate("Errors", 280, 210) GUICtrlCreateLabel("Errors found during installation:", 60, 15) GuiCtrlCreateEdit($errormsg, 15, 40, 240, 150) GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then GUIDelete($winhandle2) ExitLoop EndIf WEnd ProgressSet(100, "... Shutting System Down ") ProgressOff() ;Shutdown message If MsgBox(262192, "Upgrade Complete Restart Initiated", "Computer will automatically Restart in 30 seconds!" & _ @CRLF & @CRLF & "Press *OK* to Cancel.", 30) = -2 Then MsgBox(0,"","complete");Shutdown(9) EndIf Good Luck with this. I have added an errors box if you want to do multiple machines at once and leave them or whatever you want to do. Have fun! shanet Edited December 16, 2010 by shanet [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm Link to comment Share on other sites More sharing options...
nathancook Posted December 16, 2010 Author Share Posted December 16, 2010 Hi ShaneT and Realm, thanks so much for the input, it all works a treat. Once I have finished it off I'll post back with the final script for others to use. ShaneT, thanks for adding the error checking, I was going to look into that eventually. You saved me a few hours work Cheers Link to comment Share on other sites More sharing options...
shanet Posted December 16, 2010 Share Posted December 16, 2010 Hi ShaneT and Realm, thanks so much for the input, it all works a treat. Once I have finished it off I'll post back with the final script for others to use. ShaneT, thanks for adding the error checking, I was going to look into that eventually. You saved me a few hours work CheersWell, I am more than happy to help, and I will say that Realm is on his behalf. If there is anything else you need help with, just let us know.shanet [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now