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

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:

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.