The answer is a combination of @sodawillow and @user2460798 answers. I'm grateful that you each gave me your input. Thankyou!
- The script must define a parameter to receive the path & filename from the double-click (note that Param declarations must be prior to any other code) "Param([String]$FileNameSelected)".
- The script must use the param $FileNameSelected as an argument when launching a program.
- Associate your filename extension with your script (wrapped to an
.exe - I used PS2EXE).
Here's a sample script:
Param([String]$FileNameSelected)
$title = "Launch Menu"
$message = "Do you want to launch program A, B, or C?"
$pA = New-Object System.Management.Automation.Host.ChoiceDescription "&Notepad", "Launches Notepad."
$pB = New-Object System.Management.Automation.Host.ChoiceDescription "&B", "Launches program B."
$pC = New-Object System.Management.Automation.Host.ChoiceDescription "&C", "Launches program C."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($pA, $pB, $pC)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
switch ($result)
{
0 {
$wshell = New-Object -ComObject Wscript.Shell
$executable = 'notepad.exe'
$argument = '"' + $FileNameSelected + '"'
Start-Process $executable $argument -workingdirectory "c:\windows\system32"
}
1 {
$wshell = New-Object -ComObject Wscript.Shell
$executable = 'ProgramB.exe'
$argument = '"' + $FileNameSelected + '"'
Start-Process $executable $argument -workingdirectory "C:\Program Files (x86)\Test"
}
2 {
$wshell = New-Object -ComObject Wscript.Shell
$executable = 'ProgramC.exe'
$argument = '"' + $FileNameSelected + '"'
Start-Process $executable $argument -workingdirectory "C:\Program Files\Test"
}
}