Skip to content

opsi.orgheader image

opsi.org
Views
WinstScripts >>

7zip

Document Actions
last edited 10 months ago by sehlers
Three scripts: setup.ins, delsub.ins and uninstall.ins


Qualified for opsi 3.4
---------------------------------------------------------------------
setup.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/

[Initial]
requiredWinstVersion >= "4.8.6"
LogLevel=2
;  Log Errors in Logfile but don't abort:
ExitOnError=false
; Show syntax errors in the script:
ScriptErrorMessages=on
; Dont trace step by step through the script:
TraceMode=off
; let started programs run in front of the winst window
StayOnTop=false
 
[Aktionen]
DefVar $TEMP$ 
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $NewExe$
DefVar $InstallDir$
DefVar $ExitCode$

set $ProductId$ = "7-zip"
set $MinimumSpace$ = "10 MB"
set $InstallDir$="%ProgramFilesDir%\"+$ProductId$
set $NewExe$=$InstallDir$+"\"+"7z.exe"

Set $TEMP$ = EnvVar("TEMP")

; Message at install time:
Message "Installing "+$ProductId$+" ..."

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 /3 "%scriptpath%\7zip.png" $ProductId$

	if FileExists("%ScriptPath%\delsub.ins")
		comment  "start uninstall sub section"
		sub "%ScriptPath%\delsub.ins"
	endif

	;Message at install time:
	Message "Installing "+$ProductId$+" ..."

	comment "start setup program"  
	Winbatch_install
	sub_check_exitcode
	
	;comment "copy files"
	;Files_install
	
	;comment "set Registry"
	;Registry_install
	
	;comment "set start menu"
	;LinkFolder_install
	
	comment "test for installation success"
	if not(FileExists($NewExe$))
		logError "Fatal: After Installation "+$NewExe$+" not found"
		isFatalError
	endif

endif

[Winbatch_install]
"%SCRIPTPATH%\7z465.exe" /S

[Files_install]
; something like
; copy -sv "%SCRIPTPATH%\files\*.*" "%ProgramFilesDir%\$ProductId$"

[Registry_install]
; something like
; openkey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
; set "key"="value"

[LinkFolder_install]
; something like
; set_basefolder common_programs
; set_subfolder $ProductId$
;
; set_link
;  name: $ProductId$
;  target: $NewExe$
;  parameters:
;  working_dir: $InstallDir$
;  icon_file:
;  icon_index:
; 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

******************************************************************

delsub.ins

******************************************************************
; Message at install time:
Message "Deinstalling "+$ProductId$+" ..."

comment "start uninstall program if exists"
if FileExists($InstallDir$+"\uninstall.exe")
	Winbatch_uninstall
	sub_check_exitcode
endif 

comment "delete files"
Files_uninstall

comment "cleanup Registry"
Registry_uninstall

comment "clear start menu"
LinkFolder_uninstall

[Winbatch_uninstall]
; something like
"$InstallDir$\uninstall.exe" /S

[Files_uninstall]
; something like (don't forget the trailing backslash)
; delete -sf "$InstallDir$\"

[Registry_uninstall]
; something like
; deletekey [HKEY_LOCAL_MACHINE\Software\########]

[LinkFolder_uninstall]
; something like
; set_basefolder common_programs
; delete_subfolder $ProductId$


*******************************************************************

uninstall.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/

[Initial]
requiredWinstVersion >= "4.8.6"
LogLevel=2
;  Log Errors in Logfile but don't abort:
ExitOnError=false
; Show syntax errors in the script:
ScriptErrorMessages=on
; Dont trace step by step through the script:
TraceMode=off
; let started programs run in front of the winst window
StayOnTop=false
 
[Aktionen]
DefVar $ProductId$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $licensepool$

; This should be edited
set $ProductId$ = "7-zip"
set $InstallDir$="%ProgramFilesDir%\"+$ProductId$

DefVar $TEMP$ 
Set $TEMP$ = EnvVar("TEMP")

comment "show product picture"
ShowBitmap /3 "%scriptpath%\7zip.png" $ProductId$

if FileExists("%ScriptPath%\delsub.ins")
   comment  "start uninstall sub section"
   sub "%ScriptPath%\delsub.ins"
endif