ScubaSteve Posted November 7, 2007 Share Posted November 7, 2007 Ok I wrote a small script for installing two sequential releasees of product (there is a bug where you have to install the first version before installing the second.) Now I am having an issue where some people have the first version already installed. I need help with conditional statements and functions. First: I need to check if a file exists first and if this file exists then check the version. if the version is 9.x.x.x.x.x. then I need to install version 10 of this client. If the file does not exists or does not = 9.x.x.x.x.x.x.x. of this file then I need to proceed with my original script. Original script ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent") For $i = 1 to 49 step 1 sleep(1000) ProgressSet( $i, $i & " percent") Next Run(9_0.msi /qn Allow_Reboot=No) WinWaitActive("Installer Information") Send("!n") ProgressSet(50 , "Almost Done", "Installation In Progress, Please Wait") For $i = 50 to 99 step 1 sleep(1000) ProgressSet( $i, $i & " percent") Next Run(10_0.msi /qn Allow_Reboot=No) ProgressSet(100 , "Done", "Complete") sleep(500) ProgressOff() Link to comment Share on other sites More sharing options...
Achilles Posted November 7, 2007 Share Posted November 7, 2007 In the helpfile, which comes with the AutoIt installation, look for FileExists and FileGetVersion Welcome to the AutoIt forums My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
ScubaSteve Posted November 7, 2007 Author Share Posted November 7, 2007 In the helpfile, which comes with the AutoIt installation, look for FileExists and FileGetVersionWelcome to the AutoIt forumsHeres what I came up with but Im new to this stuff and dont know how to call a function etcGetVer()Install9to10()Upgradeto10()If FileExists("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") Else Install9to10()EndifFunc GetVer()$ver = FileGetVersion("C:\Program Files\Citrix\ICA Client\Wfica32.EXE")if $ver = "9.*" then Upgradeto10EndFuncFunc Install9to10Run("msiexec /i 9_0.msi")ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent")For $i = 1 to 24 step 1 sleep(1500) ProgressSet( $i, $i & " percent")NextProgressSet(25 , "Working", "Installation In Progress, Please Wait")For $i = 25 to 49 step 1 sleep(1000) ProgressSet( $i, $i & " percent")NextWinWaitActive("Installer Information")Send("!n")Run("msiexec /i 10_0.msi")ProgressSet(50 , "Additional Configuration", "Installation In Progress, Please Wait")For $i = 50 to 74 step 1 sleep(1800) ProgressSet( $i, $i & " percent")NextProgressSet(75 , "Almost Done", "Installation In Progress, Please Wait")For $i = 75 to 99 step 1 sleep(1000) ProgressSet( $i, $i & " percent")NextWinWaitActive("Installer Information")ProgressSet(100 , "Done", "Complete")sleep(100)ProgressOff()EndFuncFunc Upgradeto10Run("msiexec /i 10_0.msi")EndFunc Link to comment Share on other sites More sharing options...
Kerros Posted November 7, 2007 Share Posted November 7, 2007 So I'm taking a guess at what is happening here. Getver was checking to see if the program was installed and if it was just run upgradeto10. If it was not, the script needs to run install9to10. I ran Tidy within the SciTE tools menu to help clean up the code a bit, you had forgotten to include brackets () after a couple of the functions. No worries it happens. CODEIf FileExists("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") Then $version = FileGetVersion("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") If $version = "9.*" Then Upgradeto10() EndIf Else Install9to10() EndIf Func Install9to10() Run("msiexec /i 9_0.msi") ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent") For $i = 1 To 24 Step 1 Sleep(1500) ProgressSet($i, $i & " percent") Next ProgressSet(25, "Working", "Installation In Progress, Please Wait") For $i = 25 To 49 Step 1 Sleep(1000) ProgressSet($i, $i & " percent") Next WinWaitActive("Installer Information") Send("!n") Run("msiexec /i 10_0.msi") ProgressSet(50, "Additional Configuration", "Installation In Progress, Please Wait") For $i = 50 To 74 Step 1 Sleep(1800) ProgressSet($i, $i & " percent") Next ProgressSet(75, "Almost Done", "Installation In Progress, Please Wait") For $i = 75 To 99 Step 1 Sleep(1000) ProgressSet($i, $i & " percent") Next WinWaitActive("Installer Information") ProgressSet(100, "Done", "Complete") Sleep(100) ProgressOff() EndFunc ;==>Install9to10 Func Upgradeto10() Run("msiexec /i 10_0.msi") EndFunc ;==>Upgradeto10 Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
ScubaSteve Posted November 7, 2007 Author Share Posted November 7, 2007 So I'm taking a guess at what is happening here.Getver was checking to see if the program was installed and if it was just run upgradeto10. If it was not, the script needs to run install9to10.I ran Tidy within the SciTE tools menu to help clean up the code a bit, you had forgotten to include brackets () after a couple of the functions. No worries it happens.CODEIf FileExists("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") Then $version = FileGetVersion("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") If $version = "9.*" Then Upgradeto10() EndIfElse Install9to10()EndIfFunc Install9to10() Run("msiexec /i 9_0.msi") ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent") For $i = 1 To 24 Step 1 Sleep(1500) ProgressSet($i, $i & " percent") Next ProgressSet(25, "Working", "Installation In Progress, Please Wait") For $i = 25 To 49 Step 1 Sleep(1000) ProgressSet($i, $i & " percent") Next WinWaitActive("Installer Information") Send("!n") Run("msiexec /i 10_0.msi") ProgressSet(50, "Additional Configuration", "Installation In Progress, Please Wait") For $i = 50 To 74 Step 1 Sleep(1800) ProgressSet($i, $i & " percent") Next ProgressSet(75, "Almost Done", "Installation In Progress, Please Wait") For $i = 75 To 99 Step 1 Sleep(1000) ProgressSet($i, $i & " percent") Next WinWaitActive("Installer Information") ProgressSet(100, "Done", "Complete") Sleep(100) ProgressOff()EndFunc ;==>Install9to10Func Upgradeto10() Run("msiexec /i 10_0.msi")EndFunc ;==>Upgradeto10Thats exactly what Im tryuing to do. Im going to try this first thing in the morning. Thanks So Much for your help. Link to comment Share on other sites More sharing options...
ScubaSteve Posted November 9, 2007 Author Share Posted November 9, 2007 OK now I have a list of versions in the 9.x client and I cant get the script to work. Can you guys help me out?? expandcollapse popupIf FileExists("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") Then $version = FileGetVersion("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") If $version = "9.0.32649.0" Then Upgradeto10() EndIf If $version = "9.100.36280" Then Upgradeto10() EndIf If $version = "9.150.39151" Then Upgradeto10() EndIf If $version = "9.200.44376" Then Upgradeto10() EndIf If $version = "9.230.50211" Then Upgradeto10() EndIf If $version = "9.237.53063" Then Upgradeto10() EndIf Else Install9to10() EndIf Func Install9to10() ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent") For $i = 1 to 49 step 1 sleep(1000) ProgressSet( $i, $i & " percent") Next Run("msiexec /i 9_0.msi") WinWaitActive("Installer Information") Send("!n") ProgressSet(50 , "Almost Done", "Installation In Progress, Please Wait") For $i = 50 to 99 step 1 sleep(1000) ProgressSet( $i, $i & " percent") Next Run("msiexec /i 10_0.msi") ProgressSet(100 , "Done", "Complete") sleep(500) ProgressOff() EndFunc;==>Install9to10 Func Upgradeto10() ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent") Run("msiexec /i 10_0.msi") For $i = 1 to 80 step 1 sleep(1000) ProgressSet( $i, $i & " percent") Next EndFunc;==>Upgradeto10 Link to comment Share on other sites More sharing options...
ScubaSteve Posted November 9, 2007 Author Share Posted November 9, 2007 OK This looks like it is working I have to do some more with control click etc but I think this is looking promising. expandcollapse popupIf FileExists("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") Then $version = FileGetVersion("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") If $version = "9.0.32649.0" Then Upgradeto10() ElseIf $version = "9.100.36280" Then Upgradeto10() ElseIf $version = "9.150.39151" Then Upgradeto10() ElseIf $version = "9.200.44376" Then Upgradeto10() ElseIf $version = "9.230.50211" Then Upgradeto10() ElseIf $version = "9.237.53063" Then Upgradeto10() Else Install9to10() EndIf EndIf Func Install9to10() ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent") For $i = 1 to 49 step 1 sleep(1000) ProgressSet( $i, $i & " percent") Next Run("msiexec /i 9_0.msi") WinWaitActive("Installer Information") Send("!n") ProgressSet(50 , "Almost Done", "Installation In Progress, Please Wait") For $i = 50 to 99 step 1 sleep(1000) ProgressSet( $i, $i & " percent") Next Run("msiexec /i 10_0.msi") ProgressSet(100 , "Done", "Complete") sleep(500) ProgressOff() EndFunc;==>Install9to10 Func Upgradeto10() ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent") Run("msiexec /i 10_0.msi") For $i = 1 to 80 step 1 sleep(1000) ProgressSet( $i, $i & " percent") Next EndFunc;==>Upgradeto10 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