Deficiencies of New-InstallerShortcut cmdlet


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.

Change #1
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)

Change #2
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,

Change #3
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

Change #4
After checking the Wix Shortcut element documentation ( I can see the above would be an easy change, as well as adding Arguments, as well as Show behavior (Normal, Minimized, Maximized)

1 Like


I installed v5.4.1 of the Module and this time I was getting an error when creating the Shortcut, something about a null value being passed. It took me some debugging to realize that you introduced new parameters in the cmdlet: -Arguments, - WorkingDirectory and -Show, and the lack of the first two was triggering the error. I added them and the WXS was created, however WorkingDirectory is wrongly created because it should point to a folder reference like below, so I had to manually fix that in the WXS as in the other screenshot

Module 5.4.1 also introduced a bug when creating a shortcut because when the executing script is a PS1, the Target was converted to “powershell.exe” and hence the shortcut was not being created. In order to make it work, I manually changed the above string to [POWERSHELL] so it would use the Property already set in the WXS.

This has been resolved in 5.4.2.