0

dI have created an archive in 7zip. (files.7z) i created a config.txt file (I actually created 3 different ones at different times). I use the command line tool to create the sfx which works fine. but when I run the .exe I do not get the expected results. It is as if the sfx ignores the config. I put the archive and config.txt in the 7-zip install directory and my command line looks like this:

C:\Program Files\7-Zip>copy /b 7z.sfx + config.txt + files.7z files.exe

When I run that the result looks like this

7z.sfx
config.txt
files.7z
1 file(s) copied.

Here is my config. I used notepad and made sure to save as UTF-8.

;!@Install@!UTF-8!
Title="MyApp Installer"
ExecuteFile="setup.exe"
InstallPath="%temp%\\My App"
;!@InstallEnd@!

I copy the files.exe to desktop in a folder. Run and it asks me where to extract, won't run the setup.exe (in the files.7z root)

What am I doing wrong? Ive been all over the 7-zip forum and can't find my error.

timlint
  • 147
  • 2
  • 10

2 Answers2

2

You're using the wrong SFX module -- you need to use 7zS.sfx instead of 7z.sfx . IIRC, 7zS.sfx doesn't come with 7-Zip by default, you have to download the 7z<ver>-extra.7z archive from SourceForge to get it.

afrazier
  • 4,784
  • 2
  • 27
  • 30
1

According to the -sfx (Create SFX archive) switch and Command Line Version User's Guide:

SFX_Module - Specifies the SFX module that will be combined with the archive. This module must be placed in the same directory as the 7z.exe. If SFX_Module is not assigned, 7-Zip will use standard console SFX module 7zCon.sfx.

The whole process of creating installer is well documented, including an example of the config file and batch file you need to use to pack the installer. It's what you already did and posted here.

There is also a description of which module you need for the particular use-case:

SFX_Module Description

  • 7z.sfx SFX module (GUI version)
  • 7zCon.sfx SFX module (Console version)
  • 7zSD.sfx SFX module for installers (GUI version)
  • 7zS2.sfx small SFX module for installers (GUI version)
  • 7zS2con.sfx small SFX module for installers (Console version)

The file that can be used to pack an installer / .exe project is 7zSD.sfx or 7zS.sfx.

They are both made for installers. Use it if you want to create a self-extracting archive that performs the installation, extracts archive to the temporary folder during the installation, runs the specified program and cleans the temporary files up after the installation is done.

The difference between them is:

7zSD.sfx uses MSVCRT.dll, which is the C standard library for the Visual C++ (MSVC) compiler from version 4.2 to 6.0. Your self-extracting archive won't run on pure, old Windows if some other application didn’t install MSVCRT.dll on that machine. It is included with every modern Windows installation, on top of which most Windows applications are built.

Since you should be safe now days about MSVCRT.dll, using both 7zS.sfx and / or 7zSD.sfx is ok, just pick one and things should work smoothly.

There is no need to download via SourceForge anymore. In current versions of 7-Zip, the required .sfx file is not part of 7z-Extra download, it is part of the LZMA SDK.

https://www.7-zip.org/sdk.html

You need to extract LZMA SDK and copy 7zS.sfx and / or 7zSD.sfx next to the 7z.exe.

CodeSamurai
  • 623
  • 3
  • 6