New handling of old installs with a ini file

This commit is contained in:
Mario Fetka 2012-05-12 21:40:24 +02:00
parent 1160549e60
commit ba3f68ae45
6 changed files with 174 additions and 31 deletions

View File

@ -4,21 +4,31 @@
; credits: http://www.opsi.org/credits/
Set $MsiId32$ = '{93705D7B-72BB-4F37-92B1-A87E601BD0CF}'
Set $MsiId32Old$ = '{1E972AFA-D546-49F4-BF8F-86F168AC2498}'
Set $UninstallProgram32$ = $InstallDir32$ + "\uninstall.exe"
Set $UninstallProgram64$ = $InstallDir64$ + "\uninstall.exe"
Set $IniFile32$ = $InstallDir32$ + "\opsi-" + $ProductId$ + ".ini"
Set $IniFile64$ = $InstallDir64$ + "\opsi-" + $ProductId$ + ".ini"
Set $MsiId64$ = '{E274777F-0D6E-4509-A954-36B6DDEE8DAF}'
Set $MsiId64Old$ = '{3DA00A00-C3E9-4064-B62C-CAD25EAF0B6A}'
if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
Message "Uninstalling " + $ProductId$ + " 32 Bit..."
if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId32Old$ + "] DisplayName") = "")
comment "MSI id " + $MsiId32Old$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi_32_old
if FileExists($IniFile32$)
Set $MsiIdOld32$ = GetValueFromInifile($IniFile32$,"X86","MsiId32","{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}")
if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiIdOld32$ + "] DisplayName") = "")
comment "Old MSI id " + $MsiIdOld32$ + " found in registry, starting msiexec to uninstall old version"
Winbatch_uninstall_msi_old_32
sub_check_exitcode
endif
endif
if FileExists($UninstallProgram32$)
comment "Uninstall program found, starting uninstall"
Winbatch_uninstall_32
sub_check_exitcode
endif
if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId32$ + "] DisplayName") = "")
comment "MSI id " + $MsiId32$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi_32
@ -34,18 +44,26 @@ endif
if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
Message "Uninstalling " + $ProductId$ + " 64 Bit..."
if FileExists($IniFile64$)
Set $MsiIdOld64$ = GetValueFromInifile($IniFile64$,"X86_64","MsiId64","{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}")
if not (GetRegistryStringValue64("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiIdOld64$ + "] DisplayName") = "")
comment "Old MSI id " + $MsiIdOld64$ + " found in registry, starting msiexec to uninstall old version"
Winbatch_uninstall_msi_old_64
sub_check_exitcode
endif
endif
if FileExists($UninstallProgram64$)
comment "Uninstall program found, starting uninstall"
Winbatch_uninstall_64
sub_check_exitcode
endif
if not (GetRegistryStringValue64("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId64$ + "] DisplayName") = "")
comment "MSI id " + $MsiId64$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi_64
sub_check_exitcode
endif
if not (GetRegistryStringValue64("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId64Old$ + "] DisplayName") = "")
comment "MSI id " + $MsiId64Old$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi_64_old
sub_check_exitcode
endif
comment "Delete files"
Files_uninstall_64 /64Bit
comment "Cleanup registry"
@ -55,24 +73,48 @@ endif
comment "Delete program shortcuts"
LinkFolder_uninstall
[Winbatch_uninstall_msi_32_old]
msiexec /x $MsiId32Old$ /qb! REBOOT=ReallySuppress
[Winbatch_uninstall_32]
; Choose one of the following examples as basis for program uninstall
;
; === Nullsoft Scriptable Install System ================================================================
; "$UninstallProgram32$" /S
;
; === Inno Setup ========================================================================================
; "$UninstallProgram32$" /silent /norestart /SUPPRESSMSGBOXES
[Winbatch_uninstall_msi_old_32]
msiexec /x $MsiIdOld32$ /qb! REBOOT=ReallySuppress
[Winbatch_uninstall_msi_32]
msiexec /x $MsiId32$ /qb! REBOOT=ReallySuppress
[Files_uninstall_32]
delete "$IniFile32$"
; Example for recursively deleting the installation directory (don't forget the trailing backslash):
;
; delete -sf "$InstallDir32$\"
[Winbatch_uninstall_msi_64_old]
msiexec /x $MsiId64Old$ /qb! REBOOT=ReallySuppress
[Winbatch_uninstall_64]
; Choose one of the following examples as basis for program uninstall
;
; === Nullsoft Scriptable Install System ================================================================
; "$UninstallProgram64$" /S
;
; === Inno Setup ========================================================================================
; "$UninstallProgram64$" /silent /norestart /SUPPRESSMSGBOXES
[Winbatch_uninstall_msi_old_64]
msiexec /x $MsiIdOld64$ /qb! REBOOT=ReallySuppress
[Winbatch_uninstall_msi_64]
msiexec /x $MsiId64$ /qb! REBOOT=ReallySuppress
[Files_uninstall_64]
delete "$IniFile64$"
; Example for recursively deleting the installation directory (don't forget the trailing backslash):
;
; delete -sf "$InstallDir64$\"

View File

@ -0,0 +1,9 @@
[X86]
MsiId32={FFB6614F-6E61-4831-BF71-51633A718B18}
[X86_64]
MsiId64={E274777F-0D6E-4509-A954-36B6DDEE8DAF}
[COMMON]
PN=nitro.pdfreader
VERSION=2.3.1.7

View File

@ -6,16 +6,24 @@
[Actions]
requiredWinstVersion >= "4.10.8.6"
DefVar $MsiId32Old$
DefVar $MsiId32$
DefVar $MsiId64Old$
DefVar $MsiId64$
; DefVar $MsiId32$
DefVar $MsiIdOld32$
DefVar $UninstallProgram32$
DefVar $IniFile32$
; DefVar $MsiId64$
DefVar $MsiIdOld64$
DefVar $UninstallProgram64$
DefVar $IniFile64$
DefVar $IniCfgFile$
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $InstallDir32$
DefVar $InstallDir64$
DefVar $ExitCode$
DefVar $LicenseRequired$
DefVar $LicenseKey$
DefVar $LicensePool$
DefVar $INST_SystemType$
DefVar $INST_architecture$
@ -46,6 +54,9 @@ Set $MinimumSpace$ = "200 MB"
; the path were we find the product after the installation
Set $InstallDir32$ = "%ProgramFiles32Dir%\Nitro PDF\Reader 2"
Set $InstallDir64$ = "%ProgramFiles64Dir%\Nitro PDF\Reader 2"
Set $IniCfgFile$ = "%ScriptPath%\opsi-" + $ProductId$ + ".ini"
Set $LicenseRequired$ = "false"
Set $LicensePool$ = "p_" + $ProductId$
; ----------------------------------------------------------------
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
@ -56,9 +67,14 @@ else
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
if FileExists("%ScriptPath%\delsub.ins")
if FileExists("%ScriptPath%\delsub3264.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub.ins"
Sub "%ScriptPath%\delsub3264.ins"
endif
if $LicenseRequired$ = "true"
comment "Licensing required, reserve license and get license key"
Sub_get_licensekey
endif
comment "installing"
@ -95,6 +111,8 @@ endif
msiexec /i "$Install32Msi$" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=2 REBOOT=ReallySuppress
[Files_install_32]
copy "$IniCfgFile$" "$InstallDir32$"
; Example of recursively copying some files into the installation directory:
;
; copy -s "%ScriptPath%\files\*.*" "$InstallDir32$"
@ -103,6 +121,8 @@ msiexec /i "$Install32Msi$" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLU
msiexec /i "$Install64Msi$" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=2 REBOOT=ReallySuppress
[Files_install_64]
copy "$IniCfgFile$" "$InstallDir64$"
; Example of recursively copying some files into the installation directory:
;
; copy -s "%ScriptPath%\files\*.*" "$InstallDir64$"
@ -149,6 +169,38 @@ msiexec /i "$Install64Msi$" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLU
; icon_index: 2
; end_link
[Sub_get_licensekey]
comment "License management is enabled and will be used"
comment "Trying to get a license key"
Set $LicenseKey$ = demandLicenseKey ($LicensePool$)
; If there is an assignment of exactly one licensepool to the product the following call is possible:
; Set $LicenseKey$ = demandLicenseKey ("", $ProductId$)
;
; If there is an assignment of a license pool to a windows software id, it is possible to use:
; DefVar $WindowsSoftwareId$
; $WindowsSoftwareId$ = "..."
; Set $LicenseKey$ = demandLicenseKey ("", "", $WindowsSoftwareId$)
DefVar $ServiceErrorClass$
set $ServiceErrorClass$ = getLastServiceErrorClass
comment "Error class: " + $ServiceErrorClass$
if $ServiceErrorClass$ = "None"
comment "Everything fine, we got the license key '" + $LicenseKey$ + "'"
else
if $ServiceErrorClass$ = "LicenseConfigurationError"
LogError "Fatal: license configuration must be corrected"
LogError getLastServiceErrorMessage
isFatalError
else
if $ServiceErrorClass$ = "LicenseMissingError"
LogError "Fatal: required license is not supplied"
isFatalError
endif
endif
endif
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode

View File

@ -6,15 +6,22 @@
[Actions]
requiredWinstVersion >= "4.10.8.6"
DefVar $MsiId32Old$
DefVar $MsiId32$
DefVar $MsiId64Old$
DefVar $MsiIdOld32$
DefVar $UninstallProgram32$
DefVar $IniFile32$
DefVar $MsiId64$
DefVar $MsiIdOld64$
DefVar $UninstallProgram64$
DefVar $IniFile64$
DefVar $IniCfgFile$
DefVar $LogDir$
DefVar $ExitCode$
DefVar $ProductId$
DefVar $InstallDir32$
DefVar $InstallDir64$
DefVar $LicenseRequired$
DefVar $LicensePool$
DefVar $INST_SystemType$
DefVar $INST_architecture$
@ -40,6 +47,8 @@ Set $LogDir$ = "%SystemDrive%\tmp"
Set $ProductId$ = "nitro.pdfreader"
Set $InstallDir32$ = "%ProgramFiles32Dir%\Nitro PDF\Reader 2"
Set $InstallDir64$ = "%ProgramFiles64Dir%\Nitro PDF\Reader 2"
Set $LicenseRequired$ = "false"
Set $LicensePool$ = "p_" + $ProductId$
; ----------------------------------------------------------------
@ -48,8 +57,28 @@ ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
Message "Uninstalling " + $ProductId$ + " ..."
if FileExists("%ScriptPath%\delsub.ins")
if FileExists("%ScriptPath%\delsub3264.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub.ins"
Sub "%ScriptPath%\delsub3264.ins"
endif
if $LicenseRequired$ = "true"
comment "Licensing required, free license used"
Sub_free_license
endif
[Sub_free_license]
comment "License management is enabled and will be used"
comment "Trying to free license used for the product"
DefVar $result$
Set $result$ = FreeLicense($LicensePool$)
; If there is an assignment of a license pool to the product, it is possible to use
; Set $result$ = FreeLicense("", $ProductId$)
;
; If there is an assignment of a license pool to a windows software id, it is possible to use
; DefVar $WindowsSoftwareId$
; $WindowsSoftwareId$ = "..."
; set $result$ = FreeLicense("", "", $WindowsSoftwareId$)

View File

@ -13,8 +13,8 @@ version: VERSION
priority: PRIORITY
licenseRequired: False
productClasses:
setupScript: setup.ins
uninstallScript: uninstall.ins
setupScript: setup3264.ins
uninstallScript: uninstall3264.ins
updateScript:
alwaysScript:
onceScript:

View File

@ -27,4 +27,15 @@ DL_ARCH[2]="X86_64"
DL_WINST_NAME[2]=Install64Msi
# File array index for the image showing while installing the program
ICON_DL_INDEX=0
ICON_DL_INDEX=0
#OPSI_SECTION[1]="Package"
#OPSI_NAME[1]="MsiId"
#OPSI_ARCH[1]="X86"
#OPSI_VALUE[1]="{FFB6614F-6E61-4831-BF71-51633A718B18}"
WINST_NAME[0]="MsiId32"
WINST_VALUE[0]="\{FFB6614F-6E61-4831-BF71-51633A718B18\}"
WINST_NAME[1]="MsiId64"
WINST_VALUE[1]="\{E274777F-0D6E-4509-A954-36B6DDEE8DAF\}"