Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

7zip Self Extracting Archive (SFX) and .Net Installer

I am trying to create a self extracting archive for a windows application I have written. My app uses the latest .Net 4.0, and I want to include the .Net setup in the SFX installer. However, if the computer needs to install the .Net framework and reboot, it won't properly resume installing my application. I looked through the other sfx posts on the Stack sites, but none of them are problems involving a .Net installer as a prerequisite for the app.

My project produces 4 files: "App Installer.msi" "setup.exe" "WindowsInstaller-KB893803-v2-x86.exe" (in the folder "WindowsInstaller3_1") and "dotNetFx40_Client_x86_x64.exe" (in the folder "DotNetFX40Client"), all of which I believe is standard.

I use 7zip to create the SFX as follows:

First, use 7zip to compress all of the files into a single archive:

7z.exe a -r AppInstallFiles.7z *

Next, I do a binary copy with the 7zS.sfx file (used to create a self extracting installer), my config file, and the archive. The config file is as follows:

;!@Install@!UTF-8!
Title="MyApp Installer"
ExecuteFile="setup.exe"
;!@InstallEnd@!

And I copy them with the line:

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

The installer works perfectly on computers which already have .Net 4.0 My problem arises on computers which don't have the .Net Framework - I run the SFX, it extracts everything to a temp directory. Then, when setup.exe recognizes that the computer doesn't have .Net 4.0, it calls the .Net Installer. This extracts to its own temp directory and begins installing. On completion, it prompts for a reboot. Hitting "No" exits the entire install. Hitting "Yes" reboots the machine, and on logging back in there is an error: "An error occurred trying to install MyApp" with details of "Unable to locate application file 'App Installer.msi'

It appears that the problem is, when the installer hands off to the .Net installer, and the .Net installer reboots, the temp directory containing the My App install files is deleted. I have tried switching from setup.exe to using "App Installer.msi," however this simply leads to the msi reporting that the computer doesn't have .Net and suggesting a web download. As I may be installing the app in offline situations, this won't work for me.

Has anyone else tried to include the .Net installer before in a 7zip SFX, and if so how did they solve it? I'd prefer to keep using 7zip if possible, but will look into other tools if necessary.

like image 994
L.J. Avatar asked Oct 08 '22 05:10

L.J.


1 Answers

The problem is that the SFX deletes extracted files after setup.exe finishes. To avoid this you may use the InstallPath parameter:

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

But in this case extracted files will not be deleted at all. You could remove these files in your MSI, for example.

PS. If your customers will run the installer through a Remote Desktop Session you have also consider this issue

like image 95
Serghei Gorodetki Avatar answered Oct 18 '22 00:10

Serghei Gorodetki