Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm playing around with 7-Zip to create a self-extracting archive (SFX) executable. I followed the documentation, but I wasn't able to get any close. I'm using the 7-Zip 32 bit and the 7-Zip extra 32 bit.

Here is where I'm stuck first to create an SFX file you need to call the following script:

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

This will generate an archive.exe that will have the config.txt file to run the appropriate program. Here is how the config.txt file look like:

;!@Install@!UTF-8!
Title="7-Zip 4.00"
BeginPrompt="Do you want to install the 7-Zip 4.00?"
RunProgram="setup.exe"
;!@InstallEnd@!`

This will generate archive.exe.

Now further down in the documentation it tells you how to add a file. I need to compress the setup.exe file so I use the following script.

7z a -sfx a.exe setup.exe

I'm confused about this example. Do I use archive.exe instead of a.exe? And if I do that, I get an error saying archive.exe is not a supported archive type.

If I kept the name a.exe and setup.exe to the a and also added the archive.exe file into it using the previous script, and all it did was extracting the file into the local folder instead of executing it.

Why is this happening?

share|improve this question

migrated from stackoverflow.com May 15 '11 at 7:27

This question came from our site for professional and enthusiast programmers.

2 Answers 2

It's much easier to use the 7-Zip GUI to create a self-extracting archive. Choose the SFX option when creating a 7z archive.

See this wikiHow article for detailed steps.

Screenshot (with freehand circle) of 7-Zip SFX option

share|improve this answer

That's almost right.

In the step:

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

the archive.7z file is the 7-zip archive that contains all your files. This should be the last step.

Before this step, archive.7z should be created, containing setup.exe and any other files it needs. Create this using:

7z a archive.7z setup.exe
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.