How to create a self-extracting RAR archive that does not display anything at runtime?

I am trying to create a self-extracting archive that is extracted in "% USERPROFILE% \ Desktop" using WinRar. However, when I run it, it is extracted to the current SFX directory, and not to my desktop. Does the path always work to retrieve an option?

I am using a 32 bit command line module.

I also checked the β€œhide all” box for silent mode, which seems to do nothing, and the command line window still appears showing information about what was retrieved.

I want the SFX archive to extract .exe and the folder contained in the SFX file to the desktop without messages.

Any suggestions?

+8
winrar sfx
source share
2 answers

You can create an SFX RAR archive that decompresses all files and folders directly onto
"%USERPROFILE%\Desktop" without displaying a window.

This can be done using WinRAR after selecting files and folders and clicking on the Add icon in the toolbar on

  • check on the General tab the option Create SFX archive,
  • by clicking on the Advanced tab on the SFX Options button,
  • on the SFX tab General for Path to retrieve the string "%USERPROFILE%\Desktop" , which leads to the automatic selection of the Absolute path option, which is correct,
  • selection on the SFX tab Modes Hide all option,
  • select the SFX module Default.sfx on the SFX tab (WinRAR GUI SFX module),
  • closing the SFX advanced options window with the OK button ,
  • enter the General Name tab for the SFX archive,
  • and start the compression using the OK button .

The command prompt window will always be displayed if the WinCon.sfx module is used for the SFX archive, since in this case Windows automatically detects when it starts the SFX archive that it is a console application and opens a command prompt window in which the SFX console is executed.

Creating such an SFX archive can also be done using a batch file:

 @echo off echo ;The comment below contains SFX script commands>"%TEMP%\SfxOptions.txt" echo/>>"%TEMP%\SfxOptions.txt" echo Path="%%USERPROFILE%%\Desktop">>"%TEMP%\SfxOptions.txt" echo Silent=^1>>"%TEMP%\SfxOptions.txt" "%ProgramFiles%\WinRAR\Rar.exe" a -c -cfg- -ep1 -idq -m5 -mdg -r -s -sfx -y "-z%TEMP%\SfxOptions.txt" "Path\Name of your SFX.exe" "Path\Folder to add" "Path\File to add" if errorlevel 1 goto Failure del "%TEMP%\SfxOptions.txt" goto :EOF :Failure del "%TEMP%\SfxOptions.txt" echo/ echo Error on creation of "Path\Name of your SFX.exe" echo/ pause 

In this batch file, you must modify it to use:

  • The path to the WinRAR program files folder containing the version of the Rar.exe console, as well as the Default.sfx SFX module.
  • The path and name of the created SFX archive.
  • The path and name of the folder and / or file to add to the archive.

The keys used are explained in the text file Rar.txt in the WinRAR program files folder.

One more note on the -ep1 switch:

Every last slash in the name of the folder and / or file to be added to the archive is deleted from the name when a folder or file is added to the archive.

When adding a folder to the archive, RAR matters if the folder is specified with or without a backslash.

Example:

Directory tree like

  • C: \ Temp
    • Myfolder
      • Subfolder 1
      • Subfolder 2
        • File x
      • File y

compressed with

 Rar.exe a -ep1 -r C:\Temp\Demo1.rar C:\Temp\MyFolder 

with the following files and folders in the C:\Temp\Demo1.rar

  • Myfolder
    • Subfolder 1
    • Subfolder 2
      • File x
    • File y

using

 Rar.exe a -ep1 -r C:\Temp\Demo2.rar C:\Temp\MyFolder\ 

or using

 Rar.exe a -ep1 -r C:\Temp\Demo2.rar C:\Temp\MyFolder\* 

leads to the following files and folders in the C:\Temp\Demo2.rar

  • Subfolder 1
  • Subfolder 2
    • File x
  • File y
+8
source share

Mofi! I think the problem here is:

Edit the following

 "-z%TEMP%\SfxOptions.txt" 

To the next

 -z "%TEMP%\SfxOptions.txt" 
0
source share

All Articles