How do I silently install a 7-zip self-extracting archive to a specific directory?
Asked Answered
C

4

37

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?

Cay answered 16/7, 2013 at 21:33 Comment(0)
C
50

try this:

C:\> DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe -o"C:\DevKit" -y
Conservation answered 20/9, 2013 at 8:12 Comment(4)
BTW, if you wanted to extract into your current working directory, in the o argument pass ".\DevKit"Lozano
Is there a way to wait for the extraction to complete? As soon as the progress dialog appears the command exits.Proximal
@TasosLaskos, just put start /b /wait in front of the commandMacron
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)Crassulaceous
C
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

Century answered 19/8, 2015 at 20:57 Comment(3)
Well, there are multiple 7zip SFX builders around. Each of them with a little bit different CLI options. - The tool i referenced (7zip SFX (7zsfx.info) ) is meanwhile dead and gone... i will update the post.Century
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.Belting
7zsfx.info has gone, use olegscherbakov.github.io/7zSFXCallimachus
T
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.

Typhoon answered 20/3, 2017 at 14:57 Comment(1)
Pardon me, the two lines appear on one line, they should be:Typhoon
V
0

Below is what I use for Autodesk product:

Start /W %~dp0AutoCAD_2018_French_LP_Win_64bit_dlm.sfx.exe -suppresslaunch -d C:\Autodesk
Valkyrie answered 28/6, 2019 at 14:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.