I am fairly new to this so my code may be little messy. I currently have the progress bar updating after each part of the install is complete and would
like to have an overal progress and another progress bar for each install if I can have the progress update by installer some how.
#include <file.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;hides tray icon
Opt("TrayIconHide", 1)
;Sets runas username
$nm = "username"
;Sets runas domain
$dn = "domain"
;Sets runas password
$pw = "password"
;Sets jpg for installer
$Logo_jpg = @TempDir & "\Logo-au3.jpg"
FileInstall("C:\Software Distribution\ikon.jpg", $Logo_jpg, 1)
;checks for vstor
$vst = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\vsto runtime Setup\v2.0.50727", "Install")
;checks for XP SP3
$sp3 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\updates\Windows XP\SP3\KB936929", "Description")
;Checks for windows installer V2
$iv2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows XP\SP3\KB893803v2", "PackageName")
;Check for DotNet 2.0
$dt2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727", "Install")
;Sets apps dir
$apps = "C:\windows\system32\drivers\apps\"
;Sets Onstarget install path
$OT = "C:\Windows\System32\Drivers\Apps\msoffice2k7pp\OnTarget\"
Sleep(2000)
;creates gui with progress bar for install
GUICreate( "On Target 2007 plug-in installation" , 735 , 250, 0, 0)
GUICtrlCreatePic( $Logo_jpg, 0, 0, 735, 250)
GUISetBkColor (0xFFFFFF)
GUISetStyle(BitOR($WS_POPUPWINDOW, $DS_SETFOREGROUND), @SW_SHOW)
$label1 = GUICtrlCreateLabel( "",240, 12, 300, 20)
$label2 = GUICtrlCreateLabel( "",240, 30, 300, 18)
$progress1 = GUICtrlCreateProgress( 240, 54, 300, 20)
$label3 = GUICtrlCreateLabel( "",240, 80, 150, 18)
;Set gui state to show
GUISetState()
WinSetOnTop("On Target 2007 plug-in installation", "" ,1)
;updates progress bar
GUICtrlSetData($label1, "Starting On Target for Outlook 2007 install")
GUICtrlSetData($label2, "Extracting install files")
GUICtrlSetData($progress1, 0)
GUICtrlSetData($label3, "Installation 0% Complete")
;installs files
FileInstall("C:\Software Distribution\OnTarget2k7 Software\OnTarget2k7.exe", "C:\Windows\temp\OnTarget2k7.exe", 1)
If IsAdmin() Then
RunWait("C:\Windows\temp\OnTarget2k7.exe")
Else
RunAsWait( $nm, $dn, $pw, 0,"C:\Windows\temp\OnTarget2k7.exe")
EndIf
;if not admin changes permissions on log file
If Not IsAdmin() Then
RunAsWait($nm, $dn, $pw, 0, 'cacls "C:\Windows\System32\Drivers\Apps\msoffice2k7pp\OnTarget\install.log" /E /C /P "power users":C /T', $OT, @SW_HIDE)
EndIf
;updates progress bar
GUICtrlSetData($label1, "Checking for windows installer version")
GUICtrlSetData($label2, "and installing if not installed already")
GUICtrlSetData($progress1, 15)
GUICtrlSetData($label3, "Installation 15% Complete")
Sleep(2000)
;Checks for var retrieved from key
If $sp3 = "Windows XP Service Pack 3" Then
_FileWriteLog($OT & "Install.log","XP SP3 was found ")
ElseIf $sp3 <> "Windows XP Service Pack 3" Then
_FileWriteLog($OT & "Install.log","XP SP3 was not found now checking for windows installer version")
If $iv2 = "Windows Installer 3.1 (KB893803)" Then
_FileWriteLog($OT & "Install.log","Windows installer version 3.1 was found ")
ElseIf $iv2 <> "Windows Installer 3.1 (KB893803)" Then
If IsAdmin() Then
$iv31 = RunWait("WindowsInstaller-KB893803-v2-x86.exe /quiet /norestart", $OT, @SW_HIDE)
Else
$iv31 = RunAsWait($nm, $dn, $pw, 0, "WindowsInstaller-KB893803-v2-x86.exe /quiet /norestart", $OT, @SW_HIDE)
EndIf
_FileWriteLog($OT & "Install.log","Windows installer V2 installer with an error code of " & $iv31)
If $iv31 <> 0 Then Exit $iv31
EndIf
EndIf
Sleep(2000)
;updates progress bar
GUICtrlSetData($label1, "Checking to see if dotnet 2.0 is installed")
GUICtrlSetData($label2, "and installing if not installed already")
GUICtrlSetData($progress1, 25)
GUICtrlSetData($label3, "Installation 25% Complete")
Sleep(2000)
;Checks for DotNet 2.0
If $dt2 = 1 Then
_FileWriteLog($OT & "Install.log","DotNet 2.0 was found ")
Else
If IsAdmin() Then
RunWait( "C:\Windows\System32\Drivers\Apps\OnTarget2k3Plug-in\dotnetfx.exe " & "/t:C:\Windows\System32\Drivers\Apps\OnTarget2k3Plug-in\dotnet2 /C")
$dt20 = RunWait($OT & "dotnet2\install /q")
Else
RunAsWait($nm, $dn, $pw, 0, "C:\Windows\System32\Drivers\Apps\OnTarget2k3Plug-in\dotnetfx.exe " & "/t:C:\Windows\System32\Drivers\Apps\OnTarget2k3Plug-in\dotnet2 /C")
$dt20 = RunAsWait($nm, $dn, $pw, 0, $OT & "dotnet2\install /q")
EndIf
_FileWriteLog($OT & "Install.log","DotNet 2.0 was installed with an error code of " & $dt20)
If $dt20 <> 0 Then Exit $dt20
EndIf
Sleep(2000)
;updates progress bar
GUICtrlSetData($label1, "Checking to make sure outlook 2007 is installed")
GUICtrlSetData($label2, "in order to continue with install.")
GUICtrlSetData($progress1, 30)
GUICtrlSetData($label3, "Installation 30% Complete")
Sleep(2000)
;Checks for outlook 2003
If FileExists("C:\Program Files\Microsoft Office\Office12\outlook.exe") then
_FileWriteLog($OT & "Install.log","Outlook 2007 found install will continue")
ElseIf FileExists("C:\Program Files\Microsoft Office\Office11\outlook.exe") Then
_FileWriteLog($OT & "Install.log","Outlook 2003 found installation aborted")
MsgBox(0, "OnTarget 2007 Plug-in", "Outlook 2007 was not found install aborting", 180)
Exit(1)
EndIf
Sleep(2000)
;updates progress bar
GUICtrlSetData($label1, "Verified outlook 2007 was installed,")
GUICtrlSetData($label2, "now starting VSTOR install.")
GUICtrlSetData($progress1, 50)
GUICtrlSetData($label3, "Installation 50% Complete")
Sleep(2000)
If $vst = 1 Then
_FileWriteLog($OT & "Install.log","VSTOR found")
Else
If IsAdmin() Then
$vst = RunWait( $OT & "VSTOR.exe /q", $OT, @SW_HIDE)
Else
$vst = RunAsWait($nm, $dn, $pw, 0, $OT & "VSTOR.exe /q", $OT, @SW_HIDE)
EndIf
_FileWriteLog($OT & "Install.log","VSTOR install completed with an Error code of_" & $vst)
If $vst <> 0 Then Exit $vst
EndIf
Sleep(2000)
;updates progress bar
GUICtrlSetData($label1, "VSTOR was installed successfully,")
GUICtrlSetData($label2, "now starting 2007 PIA install.")
GUICtrlSetData($progress1, 70)
GUICtrlSetData($label3, "Installation 70% Complete")
Sleep(2000)
If IsAdmin() Then
$pia = RunWait( "msiexec /i o2007pia.msi /qn", $OT, @SW_HIDE)
Else
$pia = RunAsWait($nm, $dn, $pw, 0, "msiexec /i o2007pia.msi /qn", $OT, @SW_HIDE)
EndIf
_FileWriteLog($OT & "Install.log","Office 2007 PIA install completed with an Error code of_" & $pia)
If $pia <> 0 Then Exit $pia
Sleep(2000)
;updates progress bar
GUICtrlSetData($label1, "2007 PIA was installed successfully,")
GUICtrlSetData($label2, "now starting 2007 On Target plug-in install.")
GUICtrlSetData($progress1, 90)
GUICtrlSetData($label3, "Installation 90% Complete")
Sleep(2000)
If IsAdmin() Then
$oai = RunWait( "msiexec /i ikon.addins.msi /qn", $OT, @SW_HIDE)
Else
$oai = RunAsWait($nm, $dn, $pw, 0, "msiexec /i ikon.addins.msi /qn", $OT, @SW_HIDE)
EndIf
_FileWriteLog($OT & "Install.log","On Target plug-in for outlook 2003 install completed with an Error code of_" & $oai)
If $oai <> 0 Then Exit $oai
Sleep(2000)
;updates progress bar
GUICtrlSetData($label1, "2007 On Target plug-in was installed successfully,")
GUICtrlSetData($label2, "On Target plug-in has been installed along with all prerequisites.")
GUICtrlSetData($progress1, 100)
GUICtrlSetData($label3, "Installation 100% Complete")
Sleep(2000)
GUIDelete()
MsgBox(0, "On Target plug-in for 2007", "Installation is complete, restart Outlook to activate plug-in")
Exit