We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

merow
Posts: 3
Joined: Wed Aug 24, 2016 1:13 pm

7Zip and Environmental Variables

Hello,

I am having some trouble extracting a zip during installation. The goal is to extract a .zip archive using 7zip with a custom action through launching a batch file with an unzip command.

In my application folder I have 7za.exe and myzip.zip.
In my batch file in the same folder I have the command: 7za x “myzip.zip".
I believe I need to add a path variable in order to call 7za in this way, to do this I go to environment and create a new variable. I select my 7za.exe file to get the value with results in [#za.exe] and a resolved path the points to this file.

The zip does not extract during installation and no variable is added to the path. Other actions in the batch are executed, so the batch file is being run during installation.
If I have 7zip preinstalled on the machine it seems to work fine meaning the command itself works, so I assume I am making some mistake when setting the path variable.
Can someone please clarify what needs to be done to add a path variable for my 7za.exe file, or provide information on the correct way to use 7zip to extract and archive located in the same folder to the same directory. I have checked a few threads and tutorials but cant identify my issue.

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

Re: 7Zip and Environmental Variables

Hello,

We create a little sample to simulate the actions you do with your batch file.
In order to solve your problem you must create a batch file with the following line :

Code: Select all

%1 x %2 -o%3
In "Resources" section - "Files and Folders" page you can add to your project all the files needed for extraction – 7za.exe, the archive and the batch file.

Next you must create a "Launch file" custom action ( in "Custom Behavior" section - "Custom Actions" page), with sequence after "Add Resources" action group with the following configuration:
  • File To Launch: [#file.bat]
    Command Line: "[#za.exe]" "[#Res.zip]" "[APPDIR]"
    Execution Time : “When the system is being modified(deferred)”
    Execution Options : Check the “Run under the LocalSystem account with full privileges (no impersonation)”
    Execution Stage Condition: check only "Install"
In "Command Line" field it is important to put the formatted references of your file paths between double-quotes because they will contain the full path to files and if in the path is a space character, this will be misinterpreted by the batch as a variable separator.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”