
This is a tricky but not uncommon issue when running Power Automate Desktop (PAD) flows that invoke external scripts like Python via PowerShell or VBScript — especially on remote servers.
Here’s a breakdown of what might be happening and how you can work around it:
Zombie Processes: Sometimes the Python process hangs due to:
stdin, stdout)PAD Timeout Not Enforced: PAD’s timeout settings on script actions don’t always kill the underlying process, especially if the script spawns a child process (like python.exe).
Remote Desktop Session Effects: If the server is headless or the session is disconnected, some scripts may behave differently (especially if they rely on UI or environment variables).
Start-Process with Timeout Logic in PowerShellInstead of calling Python directly, use Start-Process and monitor it:
$process = Start-Process -FilePath "python.exe" -ArgumentList "script.py" -PassThru
$process | Wait-Process -Timeout 30
if (!$process.HasExited) {
$process.Kill()
Write-Output "Process killed due to timeout."
}
This gives you manual control over the timeout and ensures the process is terminated.
Wrap the script call in a try/catch block and log failures. You can then:
.bat FileSometimes calling a .bat file that wraps the Python call is more stable:
@echo off
python script.py %1
Then call the .bat from PAD or PowerShell.
Instead of looping in PAD, consider:
This isolates failures and avoids long-running loops.
Have a separate watchdog script that:
python.exe processes