how can use loop for and lists to define different versions of uninstalling a program?
Verfasst: 20 Nov 2017, 12:32
Hi,
I have a question: ''Ansys'' opsi package has 3 versions of 18.0 and 18.1 and 18.2 in my computer. Now I want to change the scripts , in which first uninstall the previos versions of 18.0 and 18.1 and also I should have uninstalling of v18.2 , and then installing v18.2.
I know that I should use
DefStringList $VersionList$
Set $VersionList$ = createStringList ('v180\', 'v181\', 'v182\')
...
for %s% in $list$ do...
but I donot know how exactly I can use these scripts , and also any other definitions?
had sombody the same problem and could help me?similar scripts?
These are my documents:
setup64.ins:
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
[Actions]
requiredWinstVersion >= "4.10.8.6"
DefVar $UninstallProgram$
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $LicensePool$
DefStringList $VersionList$
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
;$ProductId$ should be the name of the product in opsi
; therefore please: only lower letters, no umlauts,
; no white space use '-' as a seperator
Set $ProductId$ = "ansys18"
Set $MinimumSpace$ = "27000 MB"
; the path were we find the product after the installation
Set $InstallDir$ = "%ProgramFiles64Dir%\ANSYS Inc\"
Set $VersionList$ = createStringList('v180\', 'v181\', 'v182\')
; ----------------------------------------------------------------
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
isFatalError
; Stop process and set installation status to failed
else
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
if FileExists("%ScriptPath%\delsub64.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub64.ins"
endif
Message "Installing " + $ProductId$ + " ..."
comment "Start setup program"
Winbatch_install
Sub_check_exitcode
endif
[Winbatch_install]
%ScriptPath%\setup\disk1\InstallPreReqs.exe -silent
%ScriptPath%\setup\disk1\setup.exe -silent -mechapdl -ansyscust -autodyn -lsdyna -cfdpost -cfx -turbogrid -fluent -polyflow -aqwa -icemcfd -forte -aim -acp -icepak -aviewer -rsm -ug -parasolid -solidedge -solidworks_reader -adinventor_reader -acad_reader -proe_reader -ug_reader -licserverinfo "2325ansys-lic.rrzn.uni-hannover.de" -install_dir "$InstallDir$" -disablerss -lang de -media_dir2 "%ScriptPath%\setup\disk2\"
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library ... S.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
Uninstall64.ins:
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
[Actions]
requiredWinstVersion >= "4.10.8.6"
DefVar $UninstallProgram$
DefVar $LogDir$
DefVar $ExitCode$
DefVar $ProductId$
DefVar $InstallDir$
DefVar $UninstallProgram$
DefStringList $VersionList$
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
Set $ProductId$ = "ansys18"
Set $InstallDir$ = "%ProgramFiles64Dir%\ANSYS Inc\"
Set $VersionList$ = createStringList ('v180\', 'v181\', 'v182\')
; ----------------------------------------------------------------
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
Message "Uninstalling " + $ProductId$ + " ..."
if FileExists("%ScriptPath%\delsub64.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub64.ins"
endif
delsub64.ins
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
Set $UninstallProgram$ = $InstallDir$ + "\" + $VersionList$ + "\Uninstall.exe"
Message "Uninstalling " + $ProductId$ + " ..."
for %version% in $VersionList$ do Sub_uninstall
[Sub_uninstall]
if FileExists($UninstallProgram$)
comment "Uninstall program found, starting uninstall"
Winbatch_uninstall
sub_check_exitcode
endif
[Winbatch_uninstall]
$UninstallProgram$ -silent
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library ... S.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
( but I think they have some errors.)
Thanks alot.
I have a question: ''Ansys'' opsi package has 3 versions of 18.0 and 18.1 and 18.2 in my computer. Now I want to change the scripts , in which first uninstall the previos versions of 18.0 and 18.1 and also I should have uninstalling of v18.2 , and then installing v18.2.
I know that I should use
DefStringList $VersionList$
Set $VersionList$ = createStringList ('v180\', 'v181\', 'v182\')
...
for %s% in $list$ do...
but I donot know how exactly I can use these scripts , and also any other definitions?
had sombody the same problem and could help me?similar scripts?
These are my documents:
setup64.ins:
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
[Actions]
requiredWinstVersion >= "4.10.8.6"
DefVar $UninstallProgram$
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $LicensePool$
DefStringList $VersionList$
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
;$ProductId$ should be the name of the product in opsi
; therefore please: only lower letters, no umlauts,
; no white space use '-' as a seperator
Set $ProductId$ = "ansys18"
Set $MinimumSpace$ = "27000 MB"
; the path were we find the product after the installation
Set $InstallDir$ = "%ProgramFiles64Dir%\ANSYS Inc\"
Set $VersionList$ = createStringList('v180\', 'v181\', 'v182\')
; ----------------------------------------------------------------
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
isFatalError
; Stop process and set installation status to failed
else
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
if FileExists("%ScriptPath%\delsub64.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub64.ins"
endif
Message "Installing " + $ProductId$ + " ..."
comment "Start setup program"
Winbatch_install
Sub_check_exitcode
endif
[Winbatch_install]
%ScriptPath%\setup\disk1\InstallPreReqs.exe -silent
%ScriptPath%\setup\disk1\setup.exe -silent -mechapdl -ansyscust -autodyn -lsdyna -cfdpost -cfx -turbogrid -fluent -polyflow -aqwa -icemcfd -forte -aim -acp -icepak -aviewer -rsm -ug -parasolid -solidedge -solidworks_reader -adinventor_reader -acad_reader -proe_reader -ug_reader -licserverinfo "2325ansys-lic.rrzn.uni-hannover.de" -install_dir "$InstallDir$" -disablerss -lang de -media_dir2 "%ScriptPath%\setup\disk2\"
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library ... S.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
Uninstall64.ins:
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
[Actions]
requiredWinstVersion >= "4.10.8.6"
DefVar $UninstallProgram$
DefVar $LogDir$
DefVar $ExitCode$
DefVar $ProductId$
DefVar $InstallDir$
DefVar $UninstallProgram$
DefStringList $VersionList$
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
Set $ProductId$ = "ansys18"
Set $InstallDir$ = "%ProgramFiles64Dir%\ANSYS Inc\"
Set $VersionList$ = createStringList ('v180\', 'v181\', 'v182\')
; ----------------------------------------------------------------
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
Message "Uninstalling " + $ProductId$ + " ..."
if FileExists("%ScriptPath%\delsub64.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub64.ins"
endif
delsub64.ins
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
Set $UninstallProgram$ = $InstallDir$ + "\" + $VersionList$ + "\Uninstall.exe"
Message "Uninstalling " + $ProductId$ + " ..."
for %version% in $VersionList$ do Sub_uninstall
[Sub_uninstall]
if FileExists($UninstallProgram$)
comment "Uninstall program found, starting uninstall"
Winbatch_uninstall
sub_check_exitcode
endif
[Winbatch_uninstall]
$UninstallProgram$ -silent
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library ... S.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
( but I think they have some errors.)
Thanks alot.