Reputation: 33
I'm trying to write a PowerShell script for lab automation that checks if the program that runs the robot is open before opening another script using a form. I had this working until I added this logic:
$RunControl = Get-Process HxRun -ErrorAction SilentlyContinue
if ($RunControl) {
[void]$RunControlForm.Show()
} else {
Start-Process -FilePath $scriptPath
}
This works fine in opening the program in $scriptPath but when I run it again the form pops up but freezes and I can't click any buttons or anything. I think it might be related to PowerShell running in single thread? I'm new to scripting in PowerShell and don't want to spend the time to convert all this to multi-thread if I can avoid it.
Upvotes: 1
Views: 56
Reputation: 33
I actually got it working by using .ShowDialog() instead of just .Show(). the ending code is:
$RunControl = Get-Process HxRun -ErrorAction SilentlyContinue
if ($RunControl) {
[void]$RunControlForm.ShowDialog()
} else {
Start-Process -FilePath $scriptPath
}
Upvotes: 1