This shows you the differences between two versions of the page.
userspace:opsi-template [2011/10/06 11:52] ueluekmen [setup32.ins] |
userspace:opsi-template [2021/08/23 08:37] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Tested with opsi 4.0.1\\ | ||
- | Tested with opsi-winst 4.10.8 - 4.11.2.1 | ||
- | This is the official template for opsi-winst scripts.\\ | ||
- | For description have a look at the opsi-getting-started manual.\\ | ||
- | Do not copy& | ||
- | The opsi-template consists of 3 script files (setup.ins, uninstall.ins and delsub.ins).\\ | ||
- | The opsi-template scripts are existing in three different kinds: to install 32 bit software (setup32.ins), | ||
- | Here we show only the 32 bit version. | ||
- | |||
- | ==== setup32.ins ==== | ||
- | |||
- | <code winst> | ||
- | ; 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:// | ||
- | |||
- | [Actions] | ||
- | requiredWinstVersion >= " | ||
- | |||
- | DefVar $MsiId$ | ||
- | DefVar $UninstallProgram$ | ||
- | DefVar $LogDir$ | ||
- | DefVar $ProductId$ | ||
- | DefVar $MinimumSpace$ | ||
- | DefVar $InstallDir$ | ||
- | DefVar $ExitCode$ | ||
- | DefVar $LicenseRequired$ | ||
- | DefVar $LicenseKey$ | ||
- | DefVar $LicensePool$ | ||
- | |||
- | Set $LogDir$ = " | ||
- | |||
- | ; ---------------------------------------------------------------- | ||
- | ; - Please edit the following values | ||
- | ; ---------------------------------------------------------------- | ||
- | ; | ||
- | ; therefore please: only lower letters, no umlauts, | ||
- | ; no white space use ' | ||
- | Set $ProductId$ | ||
- | Set $MinimumSpace$ | ||
- | ; the path were we find the product after the installation | ||
- | Set $InstallDir$ | ||
- | Set $LicenseRequired$ = " | ||
- | Set $LicensePool$ | ||
- | ; ---------------------------------------------------------------- | ||
- | |||
- | if not(HasMinimumSpace (" | ||
- | LogError "Not enough space on %SystemDrive%, | ||
- | isFatalError | ||
- | ; Stop process and set installation status to failed | ||
- | else | ||
- | comment "Show product picture" | ||
- | ShowBitmap " | ||
- | |||
- | if FileExists(" | ||
- | comment "Start uninstall sub section" | ||
- | Sub " | ||
- | endif | ||
- | |||
- | Message " | ||
- | |||
- | if $LicenseRequired$ = " | ||
- | comment " | ||
- | Sub_get_licensekey | ||
- | endif | ||
- | |||
- | comment "Start setup program" | ||
- | Winbatch_install | ||
- | Sub_check_exitcode | ||
- | |||
- | comment "Copy files" | ||
- | Files_install /32Bit | ||
- | |||
- | comment "Patch Registry" | ||
- | Registry_install /32Bit | ||
- | |||
- | comment " | ||
- | LinkFolder_install | ||
- | |||
- | comment "Test for installation success" | ||
- | ; Test if software marked as installed in registry | ||
- | ; if (GetRegistryStringValue32(" | ||
- | ; logError " | ||
- | ; isFatalError | ||
- | ; else | ||
- | ; comment " | ||
- | ; endif | ||
- | |||
- | endif | ||
- | |||
- | [Winbatch_install] | ||
- | ; Choose one of the following examples as basis for your installation | ||
- | ; You can use $LicenseKey$ var to pass a license key to the installer | ||
- | ; | ||
- | ; === Nullsoft Scriptable Install System ================================================================ | ||
- | ; " | ||
- | ; | ||
- | ; === MSI package ======================================================================================= | ||
- | ; You may use the parameter PIDKEY=$Licensekey$ | ||
- | ; msiexec /i " | ||
- | ; | ||
- | ; === InstallShield + MSI===================================================================================== | ||
- | ; Attention: The path to the log file should not contain any whitespaces | ||
- | ; " | ||
- | ; " | ||
- | ; | ||
- | ; === InstallShield ===================================================================================== | ||
- | ; Create setup.iss answer file by running: setup.exe /r / | ||
- | ; " | ||
- | ; | ||
- | ; === Inno Setup ======================================================================================== | ||
- | ; http:// | ||
- | ; You may create setup answer file by: setup.exe / | ||
- | ; You may use an answer file by the parameter / | ||
- | ; " | ||
- | |||
- | [Files_install] | ||
- | ; Example of recursively copying some files into the installation directory: | ||
- | ; | ||
- | ; copy -s " | ||
- | |||
- | [Registry_install] | ||
- | ; Example of setting some values of an registry key: | ||
- | ; | ||
- | ; openkey [HKEY_LOCAL_MACHINE\Software\$ProductId$] | ||
- | ; set " | ||
- | ; set " | ||
- | ; set " | ||
- | |||
- | [LinkFolder_install] | ||
- | ; Example of deleting a folder from AllUsers startmenu: | ||
- | ; | ||
- | ; set_basefolder common_programs | ||
- | ; delete_subfolder $ProductId$ | ||
- | ; | ||
- | ; Example of creating an shortcut to the installed exe in AllUsers startmenu: | ||
- | ; | ||
- | ; set_basefolder common_programs | ||
- | ; set_subfolder $ProductId$ | ||
- | ; | ||
- | ; set_link | ||
- | ; name: $ProductId$ | ||
- | ; target: <path to the program> | ||
- | ; parameters: | ||
- | ; working_dir: | ||
- | ; icon_file: | ||
- | ; icon_index: | ||
- | ; end_link | ||
- | ; | ||
- | ; Example of creating an shortcut to the installed exe on AllUsers desktop: | ||
- | ; | ||
- | ; set_basefolder common_desktopdirectory | ||
- | ; set_subfolder "" | ||
- | ; | ||
- | ; set_link | ||
- | ; name: $ProductId$ | ||
- | ; target: <path to the program> | ||
- | ; parameters: | ||
- | ; working_dir: | ||
- | ; icon_file: <path to icon file> | ||
- | ; icon_index: | ||
- | ; end_link | ||
- | |||
- | [Sub_get_licensekey] | ||
- | if opsiLicenseManagementEnabled | ||
- | comment " | ||
- | |||
- | comment " | ||
- | Set $LicenseKey$ = demandLicenseKey ($LicensePool$) | ||
- | ; If there is an assignment of exactly one licensepool to the product the following call is possible: | ||
- | ; Set $LicenseKey$ = demandLicenseKey ("", | ||
- | ; | ||
- | ; 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 ("", | ||
- | |||
- | DefVar $ServiceErrorClass$ | ||
- | set $ServiceErrorClass$ = getLastServiceErrorClass | ||
- | comment "Error class: " + $ServiceErrorClass$ | ||
- | |||
- | if $ServiceErrorClass$ = " | ||
- | comment " | ||
- | else | ||
- | if $ServiceErrorClass$ = " | ||
- | LogError " | ||
- | LogError getLastServiceErrorMessage | ||
- | isFatalError | ||
- | else | ||
- | if $ServiceErrorClass$ = " | ||
- | LogError " | ||
- | isFatalError | ||
- | endif | ||
- | endif | ||
- | endif | ||
- | else | ||
- | LogError " | ||
- | isFatalError | ||
- | endif | ||
- | |||
- | |||
- | [Sub_check_exitcode] | ||
- | comment "Test for installation success via exit code" | ||
- | set $ExitCode$ = getLastExitCode | ||
- | ; informations to exit codes see | ||
- | ; http:// | ||
- | ; http:// | ||
- | if ($ExitCode$ = " | ||
- | comment "Looks good: setup program gives exitcode zero" | ||
- | else | ||
- | comment "Setup program gives a exitcode unequal zero: " + $ExitCode$ | ||
- | if ($ExitCode$ = " | ||
- | comment " | ||
- | comment " | ||
- | else | ||
- | if ($ExitCode$ = " | ||
- | comment "looks good: setup program gives exitcode 1641" | ||
- | comment " | ||
- | else | ||
- | if ($ExitCode$ = " | ||
- | comment "looks good: setup program gives exitcode 3010" | ||
- | comment " | ||
- | else | ||
- | logError " | ||
- | isFatalError | ||
- | endif | ||
- | endif | ||
- | endif | ||
- | endif | ||
- | |||
- | </ | ||
- | |||
- | |||
- | ==== delsub32.ins ==== | ||
- | |||
- | <code winst> | ||
- | ; 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:// | ||
- | |||
- | |||
- | Set $MsiId$ = ' | ||
- | Set $UninstallProgram$ = $InstallDir$ + " | ||
- | |||
- | Message " | ||
- | |||
- | if FileExists($UninstallProgram$) | ||
- | comment " | ||
- | Winbatch_uninstall | ||
- | sub_check_exitcode | ||
- | endif | ||
- | if not (GetRegistryStringValue32(" | ||
- | comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall" | ||
- | Winbatch_uninstall_msi | ||
- | sub_check_exitcode | ||
- | endif | ||
- | |||
- | comment " | ||
- | Files_uninstall /32Bit | ||
- | |||
- | comment " | ||
- | Registry_uninstall /32Bit | ||
- | |||
- | comment " | ||
- | LinkFolder_uninstall | ||
- | |||
- | [Winbatch_uninstall] | ||
- | ; Choose one of the following examples as basis for program uninstall | ||
- | ; | ||
- | ; === Nullsoft Scriptable Install System ================================================================ | ||
- | ; " | ||
- | ; | ||
- | ; === Inno Setup ======================================================================================== | ||
- | ; " | ||
- | |||
- | |||
- | [Winbatch_uninstall_msi] | ||
- | msiexec /x $MsiId$ /qb! REBOOT=ReallySuppress | ||
- | |||
- | [Files_uninstall] | ||
- | ; Example for recursively deleting the installation directory (don't forget the trailing backslash): | ||
- | ; | ||
- | ; delete -sf " | ||
- | |||
- | [Registry_uninstall] | ||
- | ; Example of deleting a registry key: | ||
- | ; | ||
- | ; deletekey [HKEY_LOCAL_MACHINE\Software\$ProductId$] | ||
- | |||
- | [LinkFolder_uninstall] | ||
- | ; Example of deleting a folder from AllUsers startmenu: | ||
- | ; | ||
- | ; set_basefolder common_programs | ||
- | ; delete_subfolder $ProductId$ | ||
- | ; | ||
- | ; Example of deleting a shortcut from AllUsers desktop: | ||
- | ; | ||
- | ; set_basefolder common_desktopdirectory | ||
- | ; set_subfolder "" | ||
- | ; delete_element $ProductId$ | ||
- | |||
- | [Sub_check_exitcode] | ||
- | comment "Test for installation success via exit code" | ||
- | set $ExitCode$ = getLastExitCode | ||
- | ; informations to exit codes see | ||
- | ; http:// | ||
- | ; http:// | ||
- | if ($ExitCode$ = " | ||
- | comment "Looks good: setup program gives exitcode zero" | ||
- | else | ||
- | comment "Setup program gives a exitcode unequal zero: " + $ExitCode$ | ||
- | if ($ExitCode$ = " | ||
- | comment " | ||
- | comment " | ||
- | else | ||
- | if ($ExitCode$ = " | ||
- | comment "looks good: setup program gives exitcode 1641" | ||
- | comment " | ||
- | else | ||
- | if ($ExitCode$ = " | ||
- | comment "looks good: setup program gives exitcode 3010" | ||
- | comment " | ||
- | else | ||
- | logError " | ||
- | isFatalError | ||
- | endif | ||
- | endif | ||
- | endif | ||
- | endif | ||
- | |||
- | </ | ||
- | |||
- | ====== The uninstall32.ins ====== | ||
- | |||
- | <code winst> | ||
- | ; 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:// | ||
- | |||
- | [Actions] | ||
- | requiredWinstVersion >= " | ||
- | |||
- | DefVar $MsiId$ | ||
- | DefVar $UninstallProgram$ | ||
- | DefVar $LogDir$ | ||
- | DefVar $ExitCode$ | ||
- | DefVar $ProductId$ | ||
- | DefVar $InstallDir$ | ||
- | DefVar $LicenseRequired$ | ||
- | DefVar $LicensePool$ | ||
- | |||
- | Set $LogDir$ = " | ||
- | |||
- | ; ---------------------------------------------------------------- | ||
- | ; - Please edit the following values | ||
- | ; ---------------------------------------------------------------- | ||
- | Set $ProductId$ | ||
- | Set $InstallDir$ | ||
- | Set $LicenseRequired$ = " | ||
- | Set $LicensePool$ | ||
- | ; ---------------------------------------------------------------- | ||
- | |||
- | |||
- | comment "Show product picture" | ||
- | ShowBitmap " | ||
- | |||
- | Message " | ||
- | |||
- | if FileExists(" | ||
- | comment "Start uninstall sub section" | ||
- | Sub " | ||
- | endif | ||
- | |||
- | if $LicenseRequired$ = " | ||
- | comment " | ||
- | Sub_free_license | ||
- | endif | ||
- | |||
- | [Sub_free_license] | ||
- | comment " | ||
- | |||
- | comment " | ||
- | 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("", | ||
- | ; | ||
- | ; 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("", | ||
- | |||
- | </ |