Forum Discussion
Brian Barton
May 24, 2024Copper Contributor
Creating Start Menu Shortcuts to Launch .CMD Files
I am looking to create an MSIX for a custom app. The app is basically dropped in a folder on C:\. I would like to create a Start Menu shortcut in ...Start Menu\Programs\NewApp and have it point to a ...
Peer-Atle
Jun 11, 2024Brass Contributor
You can make a general executable from a ps1 script and include in your MSIX package.
Use ps2exe to compile script with option noConsole
Exec.ps1
if ($args.Count -eq "0"){
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# Create the main form
$form = New-Object System.Windows.Forms.Form
$form.Text = "Usage"
$form.Size = New-Object System.Drawing.Size(350,250)
$form.StartPosition = "CenterScreen"
$form.FormBorderStyle = "FixedDialog"
# Create controls
$objTextBox1 = New-Object System.Windows.Forms.TextBox
$objTextBox1.Text = "Exec.exe <Executable> [<Arguments>] [<Workingdir>] [<Min>]"
$objTextBox1.AppendText("`r`ne.g. Exec.exe Notepad.exe C:\Temp\Inst.log `" `" Min")
$objTextBox1.AppendText("`r`n")
$objTextBox1.AppendText("`r`nFirst argument --> Executable")
$objTextBox1.AppendText("`r`nSecond argument --> Arguments")
$objTextBox1.AppendText("`r`nThird argument --> Working directory")
$objTextBox1.AppendText("`r`nFourth argument --> Execute Minimized")
$objTextBox1.AppendText("`r`n")
$objTextBox1.AppendText("`r`nArguments MUST come in the correct order")
$objTextBox1.AppendText("`r`nOmitted arguments can be replaced with `" `"")
$objTextBox1.AppendText("`r`ne.g. Exec.exe Notepad.exe `" `" C:\Windows")
$objTextBox1.Multiline = $True
$objTextBox1.ReadOnly = $True
$objTextBox1.Location = New-Object System.Drawing.Size(20,20)
$objTextBox1.Size = New-Object System.Drawing.Size(300,180)
# $objTextBox1.Scrollbars = "Vertical"
$form.Controls.Add($objTextBox1)
# Show the form
$form.ShowDialog() | Out-Null
$form.Close() }
if ($args.Length -eq "1"){
Start-Process -FilePath $args[0]}
if ($args.Length -eq "2"){
Start-Process -FilePath $args[0] -ArgumentList $args[1]}
if ($args.Length -eq "3"){
Start-Process -FilePath $args[0] -ArgumentList $args[1] -WorkingDirectory $args[2]}
if ($args.Length -eq "4"){
Start-Process -FilePath $args[0] -ArgumentList $args[1] -WorkingDirectory $args[2] -WindowStyle Minimized}
With MSIX Packaging Tool use PSF Fixup and enable In Package Context
Package files
Create AppExecutionAlias in AppxManifest.xml
Install MSIX and run: ExecExeTemplate_Exec.exe "C:\Inst\List_C.cmd"
If no arguments are specified: ExecExeTemplate_Exec.exe