Search code examples
windowspowershellbatch-fileps

Cannot kill process with powershell (Stop-Process)


I have a ps1 script (Windows 2008 R2) to kill process:

 Stop-Process -Name "c_proc".

c_proc is a program that runs in console mode. After running this script c_proc does not exit, it just keeps restarting in console mode. Another way to kill c_proc is to kill conhost.exe but it didn't work either. c_proc can exit when you type in its console windows "exit". How can I send the message "exit" to the console window via PowerShell or cmd? How can I kill c_proc?


Solution

  • This is the right code to kill the process c_proc. I found the parent process:

      Stop-Process -Name "start"
      Stop-Process -Name "c_proc"