Is there a way to run Stop-Process
after a specific program closes itself automatically?
I am trying to close my VPN client after my torrent client closes itself.
Any help is appreciated.
You are looking for Wait-Process
: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/wait-process?view=powershell-7
Wait-Process -Name "TorrentClientProcessName"
Stop-Process -Name "VPNClientProcessName "
This script waits until the Torrent client has exited and then closes VPNClient. You have to replace TorrentClientProcessName and VPNClientProcessName with their process names.