0

Scenario: Let's assume I have a script that spawns a few processes. There may be times when the script has to be aborted. Most times this is fine. However, sometimes one or two of the spawned processes remain running, and are orphaned, because the script has been killed.

Is there any way to find the processes based on their environment (specific environment strings and values set when the script ran/spawned them), and kill them?

OS: Windows 7

Sagar
  • 524
  • 3
  • 7
  • 20
  • I would assume you would know the name of each process. You could put `taskkill [name of proccess]` or using powershell use `stop-process`. – Nixphoe Nov 10 '15 at 14:25

1 Answers1

1

Powershell would be a good approach to tackling this problem. You can search the currently running processes and filter them by a number of fields. By storing the processes you want to kill in a variable you can kill them all in one swoop

Here is a TechNet Entry explaining about how to get processes in powershell: https://technet.microsoft.com/en-us/library/ee176855.aspx

As seen in the image you can pipe in a where statement to filter the information that you need.

Harvey
  • 243
  • 1
  • 6