34

The Ruby Devkit is a 7-zip based self-extracting archive.

I would like to invoke it silently without having to install 7-Zip to extract the files to a folder of my choosing, so that I can script the installation. I imagine it to be something like:

cmd> DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe /silent /dir="C:\DevKit"

But that, of course, doesn't work. What command line flags must I use to silently extract this archive into a folder of my choice?

Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
Jay Godse
  • 15,163
  • 16
  • 84
  • 131

4 Answers4

45

try this:

C:\> DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe -o"C:\DevKit" -y
florind
  • 487
  • 4
  • 4
  • 1
    BTW, if you wanted to extract into your current working directory, in the o argument pass ".\DevKit" – BuvinJ Apr 17 '15 at 12:28
  • Is there a way to wait for the extraction to complete? As soon as the progress dialog appears the command exits. – Tasos Laskos Nov 04 '15 at 15:18
  • 6
    @TasosLaskos, just put `start /b /wait` in front of the command – Kevin Feb 02 '16 at 23:33
  • 2
    I suspect it depends on how the archive is made but with, for example, the GitHub portable Git distrubution 7z.exe files, the answer from Jens A Koch is better than this one (-InstallPath rather than -o) – Will Dean Feb 23 '16 at 16:58
15

Update 2017: The tool from 7zsfx.info is now dead and gone.


Original, old post from 08-2015:

If you are trying to extract an 7zip SFX (http://7zsfx.info/) archive:

sfx.exe -y -gm2 -InstallPath="C:\\your\\target\\path"

Switches Docu

  • -y hide some prompts
  • -gm2 hides the extraction dialog completely (silent mode)
  • -InstallPath sets the target path (you need double backslashes)

7z SFX Guide

The official way to create a SFX package is to use -sfx[{name}] : Create SFX archive.

And that means the created SFX packages uses two kinds of CLI options:

  1. official CLI options from 7zSFX, and
  2. the passed through options you configured in your config, before creating the package.

    You can think of it as parameter forwarding to the packaged executable. This parameter forwarding depends on the SetEnvironment and RunProgramm configuration!

The full process:

  1. Create archive Package.7z:
    • containing Installer.msi and additional crap.cab file.
  2. Create config file config.txt:

    ;!@Install@!UTF-8!
    Title="Installation"
    SetEnvironment="strInstall=hidcon:Installer.msi /qn"
    RunProgram="%strInstall%"
    ;!@InstallEnd@!
    
  3. Now we generate Test.exe by combining sfx+config+archive into an executable.

    copy /b 7zS.sfx + config.txt + Package.7z SfxInstaller.exe

    Note: 7zS.sfx is from the official 7zip extra package.

  4. Now, when you run SfxInstaller.exe you can pass for instance /lv InstallerLog.txt to create a install log, e.g.

    SfxInstaller.exe /lv InstallerLog.txt

Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
  • Well, there are multiple 7zip SFX builders around. Each of them with a little bit different CLI options. - The tool i referenced (7zip SFX (http://7zsfx.info/) ) is meanwhile dead and gone... i will update the post. – Jens A. Koch Mar 31 '17 at 10:42
  • usually these things give you the commandline if you run with /h (like the msi thing), but 7 zip doesn't do it. It's a bit of a nuisance. – thang Mar 31 '17 at 11:28
  • 2
    http://7zsfx.info/ has gone, use https://olegscherbakov.github.io/7zSFX/ – Max Nov 19 '17 at 16:07
1

Since 7-zip is used, simply create a self-extracting archive in .exe. and run it with switches -o and -y.

I use it to save space on USB drive. For instance, I run VDiskAir application infrequently. I create a self-extracting archive of the VDiskAir program folder (about 15MB):

7z a -SFX -mx9 VDiskAir.exe [VDiskAir folder path]

NB: -mx9 is used here to maximise compression.

I create a DOS BAT to run the self-extracting VDiskAir.exe (about 5MB) created, save it as VDiskAir.bat containing:

VDiskAir.exe -o%TMP% -y

%TMP%\VDiskAir\VDisk_Air.exe

I'm not worried that the VDiskAir folder (in %TMP% extracted with VDiskAir program files) is undeleted after running VDiskAir this way, since I have a BAT script to clear %TMP% on shutting down/starting up.

ADyson
  • 57,178
  • 14
  • 51
  • 63
Hon Kong
  • 11
  • 2
0

Below is what I use for Autodesk product:

Start /W %~dp0AutoCAD_2018_French_LP_Win_64bit_dlm.sfx.exe -suppresslaunch -d C:\Autodesk
Rastalamm
  • 1,712
  • 3
  • 23
  • 32