Recently I was writing scripts that should run on a Windows 7 machine. One task was to select a file and read it. So I used the usual snippet:
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog [void]$OpenFileDialog.ShowDialog()
I ran the script from PowerShell ISE during development and everything worked fine but when the users executed the script, the file dialog did not open up. Then I came across this page here and it said ShowHelp solves the problem. I changed the script to:
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog $OpenFileDialog.ShowHelp = $true [void]$OpenFileDialog.ShowDialog()
I am not sure why, but this solved the problem and did not cause any other side effect. I am wondering what ShowHelp actual does because it seems to have no visible effect.