I created a shortcut using New-InstallerShortcut as below:
Shortcut was created as expected, however as the executing program is a PS1, the target was put literally as that, only the PS1, not prefixed by the expected “powershell.exe -NoProfile -ExecutionPolicy Bypass” and so forth, hence the script does not execute.
For the above, I have two options: (1) Have an “installation” script to edit the created LNK file in the Desktop and prefix the powershell.exe string, or convert the PS1 to EXE thus avoiding the edit of the shortcut.
The Cmdlet should have more intelligence to identify the Target value as a PS1 script, and put “Powershell.exe” as Target, and the rest of execution parameters and the PS1 script name as Arguments. If not PS1 (bat, cmd, vbs, exe, etc. leave it like is)
Add a cmdlet parameter -Argument or -Argumentlist to allow the user passing execution arguments to the running program. In my case, the CustomAction installer will prompt the user for a specific folder directory, and that needs to be added to the Target string in the shortcut as -Root . I was able to solve my problem by editing the shortcut using WScript.Shell, CreateShortcut method,
Add a Working Directory parameter to the cmdlet that could be the same directory where the component is located, referenced by an -ID . Something similar was already requested by Hakmoon at New-InstallerShortcut - Error executing shortcuts
After checking the Wix Shortcut element documentation (https://wixtoolset.org/documentation/manual/v3/xsd/wix/shortcut.html) I can see the above would be an easy change, as well as adding Arguments, as well as Show behavior (Normal, Minimized, Maximized)