Forum Navigation
You need to log in to create posts and topics.

Script to Kill Processes by Command Line Arguments

Problem

  • Processes in the Task Manager that are obsolete and need to be terminated.
  • Auto corrective action to kill stuck / freeze processes

Solution

In the example below, we have a lot of nodeJS processes weren’t terminated:

List all processes node running Server.js task

Get-WmiObject win32_process | where commandline -Like ‘node ./Server.js task*’ | Select-Object ProcessId

Validate the list and run this command to terminate

Get-WmiObject win32_process | where commandline -Like ‘node ./gulp.js task*’ | remove-wmiobject