ans
Posts: 17
Joined: Tue Jul 26, 2011 9:06 pm

Prevent installer from being run inside ZIP

Hi,

Windows shows ZIP archives like a regular folders, so users often run SETUP.exe straight from inside the (downloaded) ZIP, which does not work, because dependent files have not been extracted alongside the executable (or MSI).

I've seen other installers popping up a message, like "Installer depends on files in the ZIP ... extract ZIP now?". Is there a way to do this with AdvanvedInstaller? How would I make sure the ZIP is extracted before running SETUP.exe, or at least show a warning message?

Thanks in advance.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Prevent installer from being run inside ZIP

Hello,

We do not have support to detect if the EXE setup was launched within an archive file and require the user to first extract the archive before launching the EXE setup.

However, to achieve what you need, as a workaround, you can create a wrapper setup which will embed your archive file, extract it and launch the extracted EXE during installation. To achieve this you can proceed like this:

1. Using “Files and Folders” page from the “Resources” section you will add the archive to the “Application Folder”.
2. Right-click on the file and choose “New file operation”-”Extract archive”. In the “New Extract Archive” dialog in condition field you put “NOT installed” and check (or uncheck) the control for deleting the archive after extract and whether the unistall will remove the files extracted or not. The archive will be unpacked at install and after this all the files in the archive will be available.
3. In the “Custom Actions” page you will use “Launch file” custom action with sequence, after the “Finish Execution Action Group” with the following configuration:
  • File To Launch: [APPDIR] SETUP.exe
    Execution Time : “Immediately”
    Execution Options : Uncheck the “Wait for custom action to finish before proceeding” and “Wait for return code at the end of sequence”.
    Execution Stage Condition: check only "Install"
4. Build the project and run.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ans
Posts: 17
Joined: Tue Jul 26, 2011 9:06 pm

Re: Prevent installer from being run inside ZIP

Thanks!

That wrapper setup however, would have the same issue again: It wouldn't run unless the enclosing ZIP (that includes the ZIP plus the wrapper setup) was extracted first. This only moves the problem one level up.

Note that I can't ship a self-contained monolithic EXE, because components need to be added on a Unix server prior to download. The server is able to pack a ZIP, but probably not to run AdvancedInstaller. Therefore AI's resources live in a folder next to the installer executable, all packed in a ZIP before download.

How about checking if one of those resource files existed and showing a warning? As Windows probably only extracts the EXE to run, other files next to it are probably still hidden in the ZIP and hence can not be found.

How would I build a launch condition like that?
ans
Posts: 17
Joined: Tue Jul 26, 2011 9:06 pm

Re: Prevent installer from being run inside ZIP

Interestingly enough, when I run an arbitrary EXE in the ZIP, Windows will show a warning message, like "The application may depend on files in the compressed folder ... exctract now?" (or similar). This is exactly what I need.

Unfortunately, this does not work with the AdvancedInstaller-generated EXE.

Maybe it is merely missing a flag in its manifest or something?
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Prevent installer from being run inside ZIP

Hello,
How about checking if one of those resource files existed and showing a warning? As Windows probably only extracts the EXE to run, other files next to it are probably still hidden in the ZIP and hence can not be found.

How would I build a launch condition like that?
If the MSI is missing, the EXE will show an error message and the execution is interrupted. For any other resources, this can be done using a “Launch Condition” based on a “File search” for a resource needed, in the folder the EXE was launched.

The steps are the following :
1. Create a “File search” (in the “Custom Behavior” → “Search” page) for a file that must be extracted prior launching the EXE. As search location you should use SETUPEXEDIR, a property that stores the path of the EXE file.
2. Create a “Custom Launch Condition” (in the “Requirements” → “Launch Conditions” page) which have as condition the property the search returned and as description a message about the resources missing.
Interestingly enough, when I run an arbitrary EXE in the ZIP, Windows will show a warning message, like "The application may depend on files in the compressed folder ... exctract now?" (or similar). This is exactly what I need.

Unfortunately, this does not work with the AdvancedInstaller-generated EXE.

Maybe it is merely missing a flag in its manifest or something?
We tested the scenario with an “EXE setup with resources next to it” created with Advanced Installer and everything was fine. When we try to run the EXE inside the ZIP a message appear “ The application may depend on other compressed files in this folder.” and give the option to extract all the files or just run the EXE. Please find attached the project that we tested.
Sample.zip
(685.53 KiB) Downloaded 917 times
Can you please send us the .aip (project file) to support at advancedinstaller dot com so we can investigate its settings and test them?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ans
Posts: 17
Joined: Tue Jul 26, 2011 9:06 pm

Re: Prevent installer from being run inside ZIP

Daniel, thanks a lot for your comprehensive reply and sample project. Much appreciated!

I'm afraid we are using a different project structure. The extracted ZIP contents of the download here look like this:

Code: Select all

SETUP.exe (created by AI)
Product Resources.msi
Product Additional Resources.msi
Product Additional Resources x64.msi
CommonAppDataFolder  (with subfolders, created by AI)
The project includes the Additional Resources as prerequisites, which are installed if necessary. User runs SETUP.exe which checks prerequisites and installs stuff in CommonAppDataFolder (The files in there are provided by a Unix server individually per each download). With this setup, the warning message about extracting the ZIP does not appear.

However, I found a solution: Checking whether SETUP.exe is run inside a compressed folder (ZIP) is easy. Matching the path of the running executable against "*.zip/*" will do the trick. For instance, if the path is "C:\User\Me\Downloads\Product.zip\SETUP.exe" the installer will know it's being run from inside a compressed folder. I've written a small C++ command line utility that checks for this condition, shows a warning message and returns an error code. This utility is included with the AI project at a very early installation stage.

Feature suggestion:
I suggest you add another standard launch condition to AI that checks for ZIP in the path. It should be very easy to implement and helpful.
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Prevent installer from being run inside ZIP

Hi,

The solution you used is also easy to implement using the Advanced Installer "Launch Conditions" feature. More specific, you can add a custom launch condition that checks if the "SETUPEXEDIR" property, which stores the path of the EXE package, contains the ".zip\" string. For example:

Code: Select all

SETUPEXEDIR >< ".zip\"
Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ans
Posts: 17
Joined: Tue Jul 26, 2011 9:06 pm

Re: Prevent installer from being run inside ZIP

Wow. That's a great tip. Thanks a lot.
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Prevent installer from being run inside ZIP

You're welcome. Glad to help.

Just let us know anytime you need our assistance.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”