79683157

Date: 2025-06-28 16:19:35
Score: 1
Natty:
Report link

So I have somewhat fixed the issue. I cut down the script and have left the PowerShell window open. Now it doesn't open another instance of the script unless the PowerShell window closes. basically, it sits in the background of the desktop while msedge overtakes it, which is fine for now. The problem now is getting the window to close once msedge closes, so I need to set a condition of some sort for that.

while ($true) {
  if (-not (
    Get-Process -ErrorAction Ignore powershell | 
    Where-Object -Property MainWindowTitle | where {$_.ProcessName -eq 'powershell'}
  )) {
    # No visible Edge process? -> Restart.
    Start-Process powershell -ArgumentList "-NoExit","-File", "C:\Temp\SAPTestScripting.ps1"
    Wait-Process -Name powershell
  }
  Start-Sleep -Seconds 1
}
Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: LILDASHIEGRINGO