0

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Bryan
  • 3
  • 2

1 Answers1

0

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.

Wasif
  • 14,755
  • 3
  • 14
  • 34