Table of Contents

Eraser 6

Script by d.oertel
Comments and improvements welcome

Tested with opsi 4.0.2
Tested with opsi-winst 4.11.2.6 - 4.11.3.2
Tested with Windows XP Professional and Windows 7 (x86/x64)
dotnetfx is needed, so make a dependency
You have to deflate the original setup.exe (Eraser 6.0.10.2620.exe) (use 7-zip) to get the msi files.

http://eraser.heidi.ie/index.php

http://eraser.heidi.ie/forum/viewtopic.php?f=2&t=6629&p=27007#p27007

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/en/credits/
 
 
[Actions]
requiredWinstVersion >= "4.10.8.6"
setloglevel = 6
 
DefVar $MsiId32$
DefVar $MsiId64$
DefVar $LogDir$
DefVar $ProductId$  
DefVar $MinimumSpace$
DefVar $InstallDir$
DefVar $ExitCode$
 
Set $LogDir$ = "%SystemDrive%\tmp"
 
; ----------------------------------------------------------------
; - Please edit the following values                             -
; ----------------------------------------------------------------
Set $ProductId$       = "eraser"
Set $MinimumSpace$    = "6 MB"
; the path were we find the product after the installation
if GetSystemType = "64 Bit System"
	Set $InstallDir$      = "%ProgramFiles64Dir%\Eraser"
else
	Set $InstallDir$      = "%ProgramFiles32Dir%\Eraser"
endif
; ----------------------------------------------------------------
 
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 "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
 
	if FileExists("%ScriptPath%\delsub.ins")
		comment "Start uninstall sub section"
		Sub "%ScriptPath%\delsub.ins"
	endif
 
	Message "Installing " + $ProductId$ + " ..."
 
	comment "Start setup program"
	; The eraser setup.exe is a selfextracting exe
	; extract it with 7zip and you will get two msi files (32/64)
	ChangeDirectory "%SCRIPTPATH%"
	if GetSystemType = "64 Bit System"
		Winbatch_install_64
	else
		Winbatch_install_32
	endif
	includelog $LogDir$+"\"+$ProductId$+".install_log.txt" "10"
	Sub_check_exitcode
endif
 
[Winbatch_install_32]
msiexec /i "%ScriptPath%\eraser (x86).msi" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=1 REBOOT=ReallySuppress
 
[Winbatch_install_64]
msiexec /i "%ScriptPath%\eraser (x64).msi" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=1 REBOOT=ReallySuppress
 
[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

; 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/en/credits/
 
 
Set $MsiId64$ = '{6E5159B4-A519-41EF-80EF-AD58371515DF}'
Set $MsiId32$ = '{A45C5EC7-F13E-4414-99BE-47373935C0FE}'
 
Message "Uninstalling " + $ProductId$ + " ..."
 
killtask "eraser.exe"
if not (GetRegistryStringValue64("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId64$ + "] DisplayName") = "")
	Winbatch_uninstall_msi_64
endif
 
if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId32$ + "] DisplayName") = "")
	Winbatch_uninstall_msi_32
endif
 
comment "Delete files"
Files_uninstall /32Bit
 
[Winbatch_uninstall_msi_32]
msiexec /x $MsiId32$ /qb! REBOOT=ReallySuppress
 
[Winbatch_uninstall_msi_64]
msiexec /x $MsiId64$ /qb! REBOOT=ReallySuppress
 
[Files_uninstall]
; Example for recursively deleting the installation directory (don't forget the trailing backslash):
;
del -sf "$InstallDir$\"
 
[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

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/en/credits/
 
[Actions]
requiredWinstVersion >= "4.10.8.6"
setloglevel = 6
 
DefVar $MsiId32$
DefVar $MsiId64$
DefVar $LogDir$
DefVar $ExitCode$
DefVar $ProductId$
DefVar $InstallDir$
 
Set $LogDir$ = "%SystemDrive%\tmp"
 
; ----------------------------------------------------------------
; - Please edit the following values                             -
; ----------------------------------------------------------------
Set $ProductId$       = "eraser"
if GetSystemType = "64 Bit System"
	Set $InstallDir$      = "%ProgramFiles64Dir%\Eraser"
else
	Set $InstallDir$      = "%ProgramFiles32Dir%\Eraser"
endif
; ----------------------------------------------------------------
 
 
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
 
Message "Uninstalling " + $ProductId$ + " ..."
 
if FileExists("%ScriptPath%\delsub.ins")
	comment "Start uninstall sub section"
	Sub "%ScriptPath%\delsub.ins"
endif