Installer clean-up and fixes.
[LameXP.git] / etc / Utilities / 7zSD.cmd
bloba44adda2ebe11193933a0bf8f6d8dbbb6130105e
1 @echo off
2 setlocal ENABLEDELAYEDEXPANSION
4 REM Print help screen
5 if "%~4"=="" (
6 echo 7-Zip SFX Builder
7 echo Usage: 7zSD.cmd ^<input^> ^<output^> ^<title^> ^<fname^>
8 exit /b 1
11 REM Generate temp file names
12 set "SEVENZIP_SFX_CFG=%TMP%\~7zSD%RANDOM%%RANDOM%.cf"
13 set "SEVENZIP_SFX_ARC=%TMP%\~7zSD%RANDOM%%RANDOM%.7z"
15 REM Create the configuration file
16 echo ;^^!@Install@^^!UTF-8^^!> "%SEVENZIP_SFX_CFG%"
17 echo Title="%~3">> "%SEVENZIP_SFX_CFG%"
18 echo ExecuteFile="%~n4.exe">> "%SEVENZIP_SFX_CFG%"
19 echo ;^^!@InstallEnd@^^!>> "%SEVENZIP_SFX_CFG%"
21 REM Create the 7-Zip archive
22 "%~dp0\7za.exe" a -t7z "%SEVENZIP_SFX_ARC%" "%~1"
23 if %ERRORLEVEL% NEQ 0 (
24 del "%SEVENZIP_SFX_CFG%"
25 del "%SEVENZIP_SFX_ARC%"
26 exit /b 1
29 REM Rename the embedded file
30 "%~dp0\7za.exe" rn "%SEVENZIP_SFX_ARC%" "%~nx1" "%~n4.exe"
31 if %ERRORLEVEL% NEQ 0 (
32 del "%SEVENZIP_SFX_CFG%"
33 del "%SEVENZIP_SFX_ARC%"
34 exit /b 1
37 REM Actually build the SFX file
38 copy /b "%~dp0\7zSD.sfx" + "%SEVENZIP_SFX_CFG%" + "%SEVENZIP_SFX_ARC%" "%~2"
39 if %ERRORLEVEL% NEQ 0 (
40 del "%SEVENZIP_SFX_CFG%"
41 del "%SEVENZIP_SFX_ARC%"
42 exit /b 1
45 REM Final clean-up
46 del "%SEVENZIP_SFX_CFG%"
47 del "%SEVENZIP_SFX_ARC%"
48 exit /b 0