I have 3 instances of application running from different places. All processes have similar names.
How can I kill process that was launched from specific place?
There are two commands we can use to kill a process by name, those being killall and pkill.
To Kill Process using Process/Image Name a) Type the following command into the run prompt, to kill only the one Process, and press Enter Key. For Example - To kill Notepad, run the command as, taskkill /IM notepad.exe /F , where /F is used to kill the process forcefully.
There are two commands used to kill a process: kill – Kill a process by ID. killall – Kill a process by name.
You can get the application path:
Get-Process | Where-Object {$_.Path -like "*something*"} | Stop-Process -WhatIf
That will work for the local machine only. To terminate remote processes:
Get-WmiObject Win32_Process -Filter "ExecutablePath LIKE '%something%'" -ComputerName server1 | Invoke-WmiMethod -Name Terminate
I would like to slightly improve Shay Levy's answer, as it didn't work work well on my setup (version 4 of powershell)
Get-Process | Where-Object {$_.Path -like "*something*"} | Stop-Process -Force -processname {$_.ProcessName}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With