| 1 | ; Copyright (c) uib gmbh (www.uib.de)
|
|---|
| 2 | ; This sourcecode is owned by uib gmbh
|
|---|
| 3 | ; and published under the Terms of the General Public License.
|
|---|
| 4 | ; credits: http://www.opsi.org/en/credits/
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 | Set $MsiId$ = '{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}'
|
|---|
| 8 | Set $UninstallProgram$ = $InstallDir$ + "\uninstall.exe"
|
|---|
| 9 |
|
|---|
| 10 | Message "Uninstalling " + $ProductId$ + " ..."
|
|---|
| 11 |
|
|---|
| 12 | if FileExists($UninstallProgram$)
|
|---|
| 13 | comment "Uninstall program found, starting uninstall"
|
|---|
| 14 | Winbatch_uninstall
|
|---|
| 15 | sub_check_exitcode
|
|---|
| 16 | endif
|
|---|
| 17 | if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
|
|---|
| 18 | comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
|
|---|
| 19 | Winbatch_uninstall_msi
|
|---|
| 20 | sub_check_exitcode
|
|---|
| 21 | endif
|
|---|
| 22 |
|
|---|
| 23 | comment "Delete files"
|
|---|
| 24 | Files_uninstall /32Bit
|
|---|
| 25 |
|
|---|
| 26 | comment "Cleanup registry"
|
|---|
| 27 | Registry_uninstall /32Bit
|
|---|
| 28 |
|
|---|
| 29 | comment "Delete program shortcuts"
|
|---|
| 30 | LinkFolder_uninstall
|
|---|
| 31 |
|
|---|
| 32 | [Winbatch_uninstall]
|
|---|
| 33 | ; Choose one of the following examples as basis for program uninstall
|
|---|
| 34 | ;
|
|---|
| 35 | ; === Nullsoft Scriptable Install System ================================================================
|
|---|
| 36 | ; "$UninstallProgram$" /S
|
|---|
| 37 | ;
|
|---|
| 38 | ; === Inno Setup ========================================================================================
|
|---|
| 39 | ; "$UninstallProgram$" /silent /norestart /SUPPRESSMSGBOXES /nocancel
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | [Winbatch_uninstall_msi]
|
|---|
| 43 | msiexec /x $MsiId$ /qb! REBOOT=ReallySuppress
|
|---|
| 44 |
|
|---|
| 45 | [Files_uninstall]
|
|---|
| 46 | ; Example for recursively deleting the installation directory (don't forget the trailing backslash):
|
|---|
| 47 | ;
|
|---|
| 48 | ; delete -sf "$InstallDir$\"
|
|---|
| 49 |
|
|---|
| 50 | [Registry_uninstall]
|
|---|
| 51 | ; Example of deleting a registry key:
|
|---|
| 52 | ;
|
|---|
| 53 | ; deletekey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
|
|---|
| 54 |
|
|---|
| 55 | [LinkFolder_uninstall]
|
|---|
| 56 | ; Example of deleting a folder from AllUsers startmenu:
|
|---|
| 57 | ;
|
|---|
| 58 | ; set_basefolder common_programs
|
|---|
| 59 | ; delete_subfolder $ProductId$
|
|---|
| 60 | ;
|
|---|
| 61 | ; Example of deleting a shortcut from AllUsers desktop:
|
|---|
| 62 | ;
|
|---|
| 63 | ; set_basefolder common_desktopdirectory
|
|---|
| 64 | ; set_subfolder ""
|
|---|
| 65 | ; delete_element $ProductId$
|
|---|
| 66 |
|
|---|
| 67 | [Sub_check_exitcode]
|
|---|
| 68 | comment "Test for installation success via exit code"
|
|---|
| 69 | set $ExitCode$ = getLastExitCode
|
|---|
| 70 | ; informations to exit codes see
|
|---|
| 71 | ; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
|
|---|
| 72 | ; http://msdn.microsoft.com/en-us/library/aa368542.aspx
|
|---|
| 73 | if ($ExitCode$ = "0")
|
|---|
| 74 | comment "Looks good: setup program gives exitcode zero"
|
|---|
| 75 | else
|
|---|
| 76 | comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
|
|---|
| 77 | if ($ExitCode$ = "1605")
|
|---|
| 78 | comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
|
|---|
| 79 | comment "Uninstall of a not installed product failed - no problem"
|
|---|
| 80 | else
|
|---|
| 81 | if ($ExitCode$ = "1641")
|
|---|
| 82 | comment "looks good: setup program gives exitcode 1641"
|
|---|
| 83 | comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
|
|---|
| 84 | else
|
|---|
| 85 | if ($ExitCode$ = "3010")
|
|---|
| 86 | comment "looks good: setup program gives exitcode 3010"
|
|---|
| 87 | comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
|
|---|
| 88 | else
|
|---|
| 89 | logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
|
|---|
| 90 | isFatalError
|
|---|
| 91 | endif
|
|---|
| 92 | endif
|
|---|
| 93 | endif
|
|---|
| 94 | endif
|
|---|
| 95 |
|
|---|