Ampersand(&) in Script Installation Path Causes 'Launch File' Custom Action Failure

Having trouble running Advanced Installer? Got a bug to report? Post it all here.
Post Reply
nharrison
Posts: 1
Joined: Thu Mar 28, 2019 2:41 pm

Ampersand(&) in Script Installation Path Causes 'Launch File' Custom Action Failure

Post by nharrison » Wed May 22, 2019 4:49 pm

When creating a 'Launch File' custom action pointing to a script (.bat or .cmd) and running the resulting installer so that it installs into a path with an ampersand(&), the custom action will fail to run. The custom action works fine when using an executable (.exe).

Attached is a minimum reproduction project, which will fail to install unless the installation path is modified to take out the ampersand(&). Interestingly, it also fails to uninstall after successful installation due to the same custom action
Attachments
installPath.zip
(2.93 KiB) Downloaded 15 times

Catalin
Posts: 1528
Joined: Wed Jun 13, 2018 7:49 am

Re: Ampersand(&) in Script Installation Path Causes 'Launch File' Custom Action Failure

Post by Catalin » Thu May 23, 2019 8:09 am

Hello and welcome to Advanced Installer forums,

First of all, thanks for the provided files. I have tested this and I was indeed able to replicate the behavior.

At a first glance, this seems to be caused by an issue in what regards our "LaunchFile" custom action support. I have forwarded this to the development team and we will further investigate this. Hopefully, this will be fixed in a future version of Advanced Installer. Unfortunately, I can not give you any estimation on when this will be done. Thank you for your understanding and for bringing this to our attention.

As a workaround, you can add the .BAT file as a temporary file in your project. Unlike Advanced Installer's regular files or resources, "Temporary Files" are copied on the target machine at the beginning of the installation and are deleted at the end of it, ensuring you have access to them throughout the entire install process. Temporary Files are copied during the "CostFinalize" standard action, at the beginning of the setup and removed during the "InstallFinalize" standard action.

In order to add a temporary file to your project, simply go to "Files and Folders" page and press the "Add Temporary Files" button from the toolbar. After doing so, the .BAT file can be referenced in your "LaunchFile" custom action as it follows:

[&test.bat]

Hope this helps somehow.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Catalin
Posts: 1528
Joined: Wed Jun 13, 2018 7:49 am

Re: Ampersand(&) in Script Installation Path Causes 'Launch File' Custom Action Failure

Post by Catalin » Fri May 31, 2019 8:50 am

Hello,

Followup to my last answer:

After further investigating this, we came to the conclusion that this may not be an Advanced Installer bug, but actually a bug in what regards the method Windows uses when invoking CMD/BAT files using RUNAS and characters such as "&" and "^".

Windows uses HKEY_CLASSES_ROOT\batfile\shell\runas\command for executing a RUNAS command. That redirects the BAT file to "cmd.exe" using %SystemRoot%\System32\cmd.exe /C "%1" %*. The problem resides in "%1". This should be ""%1"" in order to avoid issues with special characters.

We will try to implement the workaround described above so we can avoid such problems in the future.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Catalin
Posts: 1528
Joined: Wed Jun 13, 2018 7:49 am

Re: Ampersand(&) in Script Installation Path Causes 'Launch File' Custom Action Failure

Post by Catalin » Tue Jul 09, 2019 12:51 pm

Hello,

This was fixed in version 16.1 of Advanced Installer, released on July 2nd, 2019.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Post Reply