실행 파일의 매개 변수는 SFX 모듈의 매개 변수와 함께 주석 파일에서 직접 지정할 수 있습니다. 여기
이 기술을 설명하는 예제 배치 파일입니다
이 배치 파일은 먼저 임시 파일 내용에 텍스트 파일
TestSetup.txt에 대한 디렉토리에 생성
@echo off
cd /D "%TEMP%"
rem Create the file for the SFX module with the SFX options.
echo ;The comment below contains SFX script commands.>TestSetup.txt
echo.>>TestSetup.txt
echo Setup=Test.bat Switch "One more parameter">>TestSetup.txt
echo Overwrite=1>>TestSetup.txt
echo Title=Test Installation>>TestSetup.txt
echo Text>>TestSetup.txt
echo {>>TestSetup.txt
echo ^<font face='Arial'^>An SFX test which just shows how SFX module runs the installer.^<br^>^<br^>Just click on button Install or hit RETURN.^</font^>>>TestSetup.txt
echo }>>TestSetup.txt
rem Create the batch file executed by SFX archive.
echo @echo %%0 %%*>Test.bat
echo @pause>>Test.bat
echo @del %%0 ^>nul>>Test.bat
rem Create the SFX archive.
RAR.exe a -sfx -c -zTestSetup.txt TestSetup.exe Test.bat
rem Delete the created batch and comment file.
del Test.bat
del TestSetup.txt
rem Run the self-extracting archive. User has to press only RETURN.
start /wait TestSetup.exe
rem Delete the self-extracting archive.
:DeleteLoop
del TestSetup.exe >nul
if exist TestSetup.exe goto DeleteLoop
:
;The comment below contains SFX script commands.
Setup=Test.bat Switch "One more parameter"
Overwrite=
Title=Test Installation
Text
{
<font face='Arial'>An SFX test which just shows how SFX module runs the installer.<br><br>Just click on button Install or hit RETURN.</font>
}
중요한 것은 Setup=
으로 시작하는 줄입니다.
Test.bat
은 압축 해제 후 실행할 파일입니다.
Switch
은 Test.bat
에 첫 번째 매개 변수로 전달하는 옵션입니다.
"One more parameter"
은 공백으로 인해 내부가 Test.bat
으로 전달되는 두 번째 매개 변수로 공백으로 인해 큰 따옴표로 묶어야합니다.
는 다음 배치 파일 내용 TEST.BAT의 생성을 계속 :
@echo %0 %*
@pause
@del %0 >nul
이 작은 배치 파일이 단지는 SFX 압축 파일에 의해 호출 된 방법 첫 번째 줄, 향후 대기로 출력 사용자가 키를 치고 마지막으로 삭제합니다. 따라서 배치 파일이 어떤 디렉토리에 추출되는지는 중요하지 않습니다. 기본값은 임시 파일의 디렉토리 인 현재 디렉토리입니다.
그런 다음 배치 파일은 SFX 보관 파일 TestSetup.exe을 만듭니다. 사용 된 스위치에 대한 자세한 내용은 프로그램 파일 디렉토리의 Rar.txtWinRAR을 참조하십시오. WinRAR과의 프로그램 파일 디렉토리 환경 변수 PATH에 포함 또는 Windows가 WinRAR과의 콘솔 버전입니다 Rar.exe
을 찾는데 실패하면 Rar.exe
있는 행은 수정없이 작동
Pleae 노트. Rar.exe
의 전체 경로를 큰 따옴표로 수정하여 포함 된 디렉토리에서 독립적으로 작업하는 배치 파일의 행을 경로으로 가져옵니다.SFX RAR 아카이브를 만든 후 더 이상 필요하지
, 파일 TEST.BAT 및 TestSetup.txt이 삭제됩니다.
이제 생성 된 SFX 아카이브 TestSetup.exe라는 키 RETURN을 타격 후하고 TEST.BAT이 TestSetup.txt에 지정된대로 2 개 매개 변수라는 것을 볼 수있다.
배치 파일은 마지막으로 생성 된 SFX 아카이브도 삭제합니다.
감사합니다. 자세한 설명은 Mofi. 나는 똑같은 것을 시도했지만 그것은 나를 위해 일하지 않았다. WinRar의 한 엔지니어와 이야기를 나누었고 WinRar에 exe 이름이 큰 따옴표 안에 들어있는 경우 버그가 있다고 동의했습니다. 예를 들어 Setup = Test.bat가 작동했지만 Setup = "Test.bat"가 작동하지 않습니다. –
감사! 내 비슷한 질문 (대답) –
자동화 된 SFX 아카이브 만들기를 사용하면 WinRAR의 기본 설정 종속성을 피하기 위해 -cfg-switch를 사용해야한다고 생각할 수 있습니다. 그렇지 않으면 WinRAR 기본 설정이 -zOptions.txt 파일 내용을 무시할 수 있습니다. http://stackoverflow.com/a/24598044/378115에서 스위치를 사용하여 다른 Mofi의 예를 찾을 수 있습니다. 고마워 Mofi –