I have written a GUI app in PowerShell. It has one parameter.
At the beginning of the script I have:
param (
[string]$Path
)
Before the Form appears, I fill in a control with $Path
:
$Form.Add_Load({
$txtSourceFile.Text = $Path
})
When I run the script interactively in PowerShell it seems to be working as expected. The txtSourceFile
control is filled in with the argument from the command line.
.\ghead.ps1 -Path C:\src\data\ghead.ps1
However, when I run this as a File Explorer extension, it does not appear to receive the argument from the command line. The registry setting for the command is:
C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.EXE C:\\Users\\lit\\bin\\ghead.ps1 -Path %1
There is no error message. It simply does not fill in the $txtSourceFile.Text
field. Am I missing something obvious? How can I get this to work?
The question suggested as a duplicate does not deal with running as a Windows File Explorer extension. I am already using the param() technique.