Calling PowerShell Commands
- Updated2025-04-10
- 1 minute(s) read
Create a custom execute to call a PowerShell command after you install a package. For example, you can invoke a PowerShell command to create a custom Windows shortcut that includes arguments.
- Select [System(64-bit)] in the Root drop-down.
-
Set the Executable Path to the path of the PowerShell
executable:
WindowsPowerShell\v1.0\powershell.exe
-
Enter the following PowerShell commands in the Arguments
field to create a shortcut:
-Command "$WScriptShell = New-Object -ComObject 'WScript.Shell'; $Shortcut = $WScriptShell.CreateShortcut('<ShortcutPath>.lnk'); $Shortcut.Arguments = '<Arguments>'; $Shortcut.TargetPath = '<TargetPath>'; $Shortcut.Save()"
Replace <ShortcutPath> with the full path for the shortcut you want to create, <TargetPath> with the full path to the executable or directory the shortcut launches, and <Arguments> to pass to the shortcut operation.
The following custom execute launches notepad.exe and opens an installed text file:
-Command "$WScriptShell = New-Object -ComObject 'WScript.Shell'; $Shortcut = $WScriptShell.CreateShortcut('%programfiles%\SomeFolder\Notepad_Args.lnk'); $Shortcut.Arguments = '%programfiles%\SomeFolder\SomeTextFile.txt'; $Shortcut.TargetPath = '%system%\notepad.exe'; $Shortcut.Save()"
- Click OK.
- Build your package by selecting .