Register-ObjectEvent `
-InputObject $balloon `
-EventName Click `
-SourceIdentifier BalloonClicked `
-ErrorAction Inquire `
-Action {
[Globals]::RequestEnd = $true
Start-Process "explorer.exe"
} | Out-Null
while (-not [Globals]::RequestEnd) {
Start-Sleep -Milliseconds 100
}
我有这段代码,当给定的通知出现时,该进程将启动进程 explorer.exe (并同时停止脚本)。当脚本以其名称.\script.ps1
启动时,我可以单击NotifyIcon并显示explorer.exe。但是,当脚本Start-Job -FilePath .\script.ps1
像后台任务一样启动时,该脚本似乎永远不会结束,并且进程也永远不会显示。
image of the output job still in running state
那么,在后台作业中,如何启动流程?