Question

So every time I turn on my company owned development machine I have to kill 10+ processes using the task manager or any other process management app just to get decent performance out of my IDE. Yes, these are processes from programs that my company installs on my machine for security and compliance. What I'd like to do is have a .bat file or script of some kind that I can just fire off and kill the processes in question.

Anybody already know how to do this?

Was it helpful?

Solution

You can do this with 'taskkill'. With the /IM parameter, you can specify image names. Example:

taskkill /im somecorporateprocess.exe

You can also do this to 'force' kill:

taskkill /f /im somecorporateprocess.exe

Just add 1 line per process you want to kill, save as a .bat file, and put in in your startup directory. Problem solved!

If this is a legacy system, PsKill will do the same.

OTHER TIPS

taskkill /f /im "devenv.exe"

this will forcibly kill the pid with the exe name "devenv.exe"

equivalent to -9 on the nix'y kill command

As TASKKILL might be unavailable on some Home/basic editions of windows here some alternatives:

TSKILL processName

or

TSKILL PID

Have on mind that processName should not have the .exe suffix and is limited to 18 characters.

Another option is WMIC :

wmic Path win32_process Where "Caption Like 'MyProcess.exe'" Call Terminate

wmic offer even more flexibility than taskkill .With wmic Path win32_process get you can see the available fileds you can filter.

I'm assuming as a developer, you have some degree of administrative control over your machine. If so, from the command line, run msconfig.exe. You can remove many processes from even starting, thereby eliminating the need to kill them with the above mentioned solutions.

Get Autoruns from Mark Russinovich, the Sysinternals guy that discovered the Sony Rootkit... Best software I've ever used for cleaning up things that get started automatically.

Download PSKill. Write a batch file that calls it for each process you want dead, passing in the name of the process for each.

Use Powershell! Built in cmdlets for managing processes. Examples here (hard way), here(built in) and here (more).

Please find the below logic where it works on the condition.

If we simply call taskkill /im applicationname.exe, it will kill only if this process is running. If this process is not running, it will throw an error.

So as to check before takskill is called, a check can be done to make sure execute taskkill will be executed only if the process is running, so that it won't throw error.

tasklist /fi "imagename eq applicationname.exe" |find ":" > nul

if errorlevel 1 taskkill /f /im "applicationname.exe"

Here I wrote an example command that you can paste in your cmd command line prompt and is written for chrome.exe.

FOR /F "tokens=2 delims= " %P IN ('tasklist /FO Table /M "chrome*" /NH') DO (TASKKILL /PID %P)

The for just takes all the PIDs listed on the below tasklist command and executes TASKKILL /PID on every PID

tasklist /FO Table /M "chrome*" /NH

If you use the for in a batch file just use %%P instead of %P

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top