2011-06-24 16:51:20 +02:00
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
2013-03-08 16:51:28 +01:00
; credits: http://www.opsi.org/en/credits/
2011-06-24 16:51:20 +02:00
[Actions]
2013-03-08 16:51:28 +01:00
requiredWinstVersion >= "4.11.2.6"
2011-06-24 16:51:20 +02:00
2012-05-13 09:30:28 +02:00
DefVar $MsiIdOld32$
DefVar $IniFile32$
DefVar $MsiIdOld64$
DefVar $IniFile64$
DefVar $IniCfgFile$
2011-06-24 16:51:20 +02:00
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $InstallDir32$
DefVar $InstallDir64$
DefVar $ExitCode$
DefVar $INST_SystemType$
DefVar $INST_architecture$
2013-03-10 15:56:24 +01:00
DefVar $OLD_VERSION$
DefVar $OLD_CREATOR_TAG$
DefVar $OLD_RELEASE$
2011-06-24 16:51:20 +02:00
2013-05-06 19:07:15 +02:00
DefVar $InstallDir$
DefVar $ProgExe$
2011-06-24 16:51:20 +02:00
Set $INST_SystemType$ = GetSystemType
set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
Set $LogDir$ = "%SystemDrive%\tmp"
2012-05-13 09:30:28 +02:00
; The token BUILDER_VARIABLES will be replaced by opsi-builder.sh
; and adds the following variables:
; from builder-product.cfg : all variables definded by attribute WINST[index]
; from builder-product.cfg : VENDOR PN VERSION RELEASE PRIORITY ADVICE TYPE
; from opsi-builder.cfg : CREATOR_TAG CREATOR_NAME CREATOR_EMAIL
; auto generated winst-variables
; $IconFile$: path to product picture
;
2012-01-28 23:17:50 +01:00
@@BUILDER_VARIABLES@@
2011-06-24 16:51:20 +02:00
; ----------------------------------------------------------------
; - 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
2013-03-10 15:56:24 +01:00
Set $MinimumSpace$ = "1 MB"
2011-06-24 16:51:20 +02:00
; the path were we find the product after the installation
Set $InstallDir32$ = "%ProgramFiles32Dir%\7-Zip"
Set $InstallDir64$ = "%ProgramFiles64Dir%\7-Zip"
; ----------------------------------------------------------------
2013-03-08 16:51:28 +01:00
Set $IniCfgFile$ = "%ScriptPath%\opsi-" + $ProductId$ + ".ini"
2011-06-24 16:51:20 +02:00
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"
2013-03-10 15:56:24 +01:00
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $NAME$
2011-06-24 16:51:20 +02:00
2012-05-13 09:30:28 +02:00
if FileExists("%ScriptPath%\delsub3264.ins")
2011-06-24 16:51:20 +02:00
comment "Start uninstall sub section"
2012-05-13 09:30:28 +02:00
Sub "%ScriptPath%\delsub3264.ins"
2011-06-24 16:51:20 +02:00
endif
comment "installing"
if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
2013-03-10 15:56:24 +01:00
Message "Installing " + $ProductId$ + " "+ $VERSION$ + "-" + $CREATOR_TAG$ + $RELEASE$ + " 32 Bit..."
2011-06-24 16:51:20 +02:00
comment "Start setup program"
2013-03-08 16:51:28 +01:00
ChangeDirectory "%SCRIPTPATH%"
2011-06-24 16:51:20 +02:00
Winbatch_install_32
Sub_check_exitcode
2013-05-06 19:07:15 +02:00
Set $InstallDir$ = $InstallDir32$
Set $ProgExe$ = $Prog32$
DosInAnIcon_install winst /32bit
2012-05-13 09:30:28 +02:00
Sub_check_exitcode
2011-06-24 16:51:20 +02:00
comment "Copy files"
Files_install_32 /32Bit
comment "Patch Registry"
Registry_install /32Bit
comment "Create shortcuts"
LinkFolder_install
endif
if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
2013-03-10 15:56:24 +01:00
Message "Installing " + $ProductId$ + " " + $VERSION$ + "-" + $CREATOR_TAG$ + $RELEASE$ + " 64 Bit..."
2011-06-24 16:51:20 +02:00
comment "Start setup program"
2013-03-08 16:51:28 +01:00
ChangeDirectory "%SCRIPTPATH%"
2011-06-24 16:51:20 +02:00
Winbatch_install_64
Sub_check_exitcode
2013-05-06 19:07:15 +02:00
Set $InstallDir$ = $InstallDir64$
Set $ProgExe$ = $Prog64$
DosInAnIcon_install winst /64bit
2012-05-13 09:30:28 +02:00
Sub_check_exitcode
2011-06-24 16:51:20 +02:00
comment "Copy files"
Files_install_64 /64Bit
comment "Patch Registry"
Registry_install /64Bit
comment "Create shortcuts"
LinkFolder_install
endif
endif
2013-05-06 19:07:15 +02:00
[DosInAnIcon_install]
2012-05-13 09:30:28 +02:00
@echo off
2013-05-06 19:07:15 +02:00
If exist "%System%\defaultassociations.xml" (copy "%System%\defaultassociations.xml" "$LogDir$") ELSE (copy "%ScriptPath%\defaultassociations.xml" "$LogDir$")
SET Prog=$ProgExe$
SET Prog=%Prog:~0,-4%
2012-05-13 09:30:28 +02:00
SET SC=HKLM\Software\Classes
SET Extn=001-9 7z-0 arj-4 bz2-2 bzip2-2 cab-7 cpio-7 deb-11 dmg-17 gz-14 fat-21 gz-14 gzip-14 hfs-18 iso-8 lha-6 lzh-6 lzma-16 ntfs-22 rar-3 rpm-10 split-9 squashfs-24 swm-15 tar-13 taz-5 tbz-2 tbz2-2 tgz-14 tpz-14 txz-23 vhd-20 wim-15 xar-19 xz-23 z-5 zip-1001-9 7z-0 arj-4 bz2-2 bzip2-2 cab-7 cpio-7 deb-11 dmg-17 gz-14 fat-21 gz-14 gzip-14 hfs-18 iso-8 lha-6 lzh-6 lzma-16 ntfs-22 rar-3 rpm-10 split-9 squashfs-24 swm-15 tar-13 taz-5 tbz-2 tbz2-2 tgz-14 tpz-14 txz-23 vhd-20 wim-15 xar-19 xz-23 z-5 zip-1
FOR %%j IN (%Extn%) DO (
2013-05-06 19:07:15 +02:00
FOR /F "tokens=1,2 delims=-" %%A IN ("%%j") DO (
REG ADD %SC%\.%%A /VE /D "7-Zip.%%A" /F
REG ADD %SC%\7-Zip.%%A /VE /D "%%A Archive" /F
REG ADD %SC%\7-Zip.%%A\DefaultIcon /VE /D "$InstallDir$\7z.dll,%%B" /F
REG ADD %SC%\7-Zip.%%A\shell\open\command /VE /D "\"$InstallDir$\7zFM.exe\" \"%%1\"" /F
copy "$LogDir$\defaultassociations.xml" "$LogDir$\defaultassociations.xml.old"
xml ed -d /DefaultAssociations/Association[@Identifier='.%%A'] "$LogDir$\defaultassociations.xml.old"> "$LogDir$\defaultassociations.xml"
copy "$LogDir$\defaultassociations.xml" "$LogDir$\defaultassociations.xml.old"
xml ed -s /DefaultAssociations -t elem -n Association_new -v "" -i /DefaultAssociations/Association_new -t attr -n Identifier -v .%%A -i /DefaultAssociations/Association_new -t attr -n ProgId -v 7-Zip.%%A -i /DefaultAssociations/Association_new -t attr -n ApplicationName -v "7-Zip file archiver" -r "/DefaultAssociations/Association_new" -v Association "$LogDir$\defaultassociations.xml.old"> "$LogDir$\defaultassociations.xml"
)
2012-05-13 09:30:28 +02:00
)
2013-05-06 19:07:15 +02:00
rem Set Default Associations for Windows 8
move "$LogDir$\defaultassociations.xml" "%System%"
REG ADD HKLM\Software\Policies\Microsoft\Windows\System /V DefaultAssociationsConfiguration /D "%System%\defaultassociations.xml" /F
[Winbatch_install_32]
msiexec /i "$Install32Msi$" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=1 REBOOT=ReallySuppress
2014-11-20 17:27:48 +01:00
addpath pre "$InstallDir32$"
2013-03-10 15:56:24 +01:00
2011-06-24 16:51:20 +02:00
[Files_install_32]
2013-03-08 16:51:28 +01:00
; copy the ini file to the InstallDir
2012-05-13 09:30:28 +02:00
copy "$IniCfgFile$" "$InstallDir32$"
2011-06-24 16:51:20 +02:00
; Example of recursively copying some files into the installation directory:
;
; copy -s "%ScriptPath%\files\*.*" "$InstallDir32$"
[Winbatch_install_64]
2013-03-08 16:51:28 +01:00
msiexec /i "$Install64Msi$" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=1 REBOOT=ReallySuppress
2014-11-20 17:27:48 +01:00
addpath pre "$InstallDir64$"
2012-05-13 09:30:28 +02:00
2011-06-24 16:51:20 +02:00
[Files_install_64]
2013-03-08 16:51:28 +01:00
; copy the ini file to the InstallDir
2012-05-13 09:30:28 +02:00
copy "$IniCfgFile$" "$InstallDir64$"
2011-06-24 16:51:20 +02:00
; Example of recursively copying some files into the installation directory:
;
; copy -s "%ScriptPath%\files\*.*" "$InstallDir64$"
[Registry_install]
; Example of setting some values of an registry key:
;
; openkey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
; set "name1" = "some string value"
; set "name2" = REG_DWORD:0001
; set "name3" = REG_BINARY:00 af 99 cd
[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: $InstallDir$
; 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: <some_param>
; working_dir: $InstallDir$
; icon_file: <path to icon file>
; icon_index: 2
; end_link
[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/aa372835(VS.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