0

I have RAR SFX with some programs. Depending on some conditions (command line parameter is something i can do), SFX should either extract to TEMP folder, or the current folder.

It's basicaly new version of the software. If downloaded from the web, extraction should go into temp folder, and then installation searches for the map where SW is located. If downloaded from inside the program, then i know the program location relative to download path and extraction should go into current folder...

Any way I can achieve this using RAR SFX?

TNX.

kzendra
  • 31
  • 1
  • 5
  • It is not clear for me what you want to do, but I think it is possible. But your question is off-topic for Stack Overflow with just a task description, see help topic [What topics can I ask about here?](http://stackoverflow.com/help/on-topic) *WinRAR* has a help which explains in detail all SFX options available. You should start with reading in help about those options. – Mofi Mar 18 '16 at 18:28

2 Answers2

1

Inside your program you can skip SFX header of file and extract it as regular RAR file in folder yo want. It need few lints of code or embding Winrar or 7zip liraries.

eri
  • 3,133
  • 1
  • 23
  • 35
1

This batch code show you how we can create an SFX (SelF-eXtracting) protected with a password and with a custom icon too if you want to add them of course

@echo off
Set SFX_Name=TestSFX.exe
Set SfxOptions=SfxOptions.txt
Set AddFile=MyBatchFile.bat
Set Icon=HackooIcon.ico
Set Winrar="%ProgramFiles%\WinRAR\WinRar.exe"
Set ExtractedPath=%tmp%\hackoo
Set Setup=%ExtractedPath%\MyBatchFile.bat
Set Password=hackoo123

(
    echo ;The comment below contains SFX script commands
    echo Path="%ExtractedPath%"
    echo Silent=1
    echo OverWrite=1
    echo Setup="%Setup%"
)> "%SfxOptions%"

%Winrar% a -c -cfg- -ep1 -idq -m5 -mdg -r -s -sfx -y -iicon"%Icon%" -hp"%Password%" "-z%SfxOptions%" "%SFX_Name%" "%AddFile%"
if errorlevel 1 goto Failure
::del "%~dp0SfxOptions.txt"
goto :EOF

:Failure
::del "%~dp0SfxOptions.txt"
echo.
echo Error on creation of "%~dp0%SFX_Name%"
echo.
pause

For others switchs and commands you can execute this batch to open the help file of Winrar :

@echo off
Set WinrarHelp=%ProgramFiles%\WinRAR\WinRAR.chm
Start "" "%WinrarHelp%"
Hackoo
  • 18,337
  • 3
  • 40
  • 70