Mark Pearl

Creating a self extracting exe and running script

As see on this original post helpful comments

I create my self extracting files using 7 zip. I find it very convenient. I’ve attached all of the files needed in a zip file. Just save the contents somewhere on your hard disk and then follow my instructions below. You can get to the creators website at “http://7zsfx.solta.ru/en/” I tweaked my setup to prompt for elevation on execute. I’d have to fumble around to figure out how to do that again if anyone is interested.

Place the files you would like to be part of your install inside the “Bin” folder. Modify the config.txt file to point to the file you want to run after extraction. For example, if you wanted the SFX to run “install.bat” upon execution, change the config.txt file to say RunProgram=”install.bat” If you want to run a vbscript as part of the install, change it to say RunProgram=”wscript.exe install.vbs” Next, click on “Create.cmd”. This will create the base program. After the DOS box closes, you should see, “Program_name.exe” appear. Rename this to an appropriate name. You’re done! When you run this file, it will extract the contents to a temporary folder, run the executable, and then delete the temporary folder when completed.

Considerations:
The command line that you run cannot include spaces in names since you are unable to use quotation marks in this field. A work around would be to point to “install.bat” and then have your complex commands inside that. You can escape your quotes with a back slash ‘' Example: "%programfiles%\Firefox" One of the nice parts about using this system is that it really is very simple. Once you have the hang of it, you can make/change installs very quickly and efficiently. Especially since once your initial settings are tweaked for an install, you can make revisions by just clicking “create.cmd” and then renaming the “Program_name.exe” to the appropriate name.

Configurable Settings
(edit the file names below in notepad to change settings)

Config.txt  
-GUIMode  
    2 = Silent extraction.  
    1 = Progress bar during extraction, but can't cancel extraction/install.  
    0 = Progress bar during extraction with cancel button during extraction/install.  
-RunProgram   Enter the command you want to run as part of the SFX.   You can use a special command to hide the output of batch files.  Set the program to RunProgram="hidcon:install.bat" and the batch file will not be visible as it runs.  This is critical for making silent installs when using batch files.  
 
Create.cmd  
--mx   Compression level.  9 is highest compression.  0 is no compression.  Using 0 is a good option for large installs that are already mostly compressed.  For example, Lotus Notes only goes down by a few percent with 9 compression, but the install takes several minutes longer to uncompress.  Using 0 is recommended for things like that.  

Example File for Creating Self Extracting Installer



blog comments powered by Disqus

Want to get my personal insights on what I learn as I learn it? Subscribe now!


/