Search code examples
batch-filecmdtaskkilltaskkill

Command line alternative to Windows' taskkill.exe


First off, please don't attack me if I am posting this in the wrong spot. That happened to me earlier on Server Fault and I don't need it happening again.

Anyway, I've been working on writing some batch scripts, and I need a good Command Line taskkill.exe alternative to kill a program before it executes another command. For example:

@echo off
echo Killing task . . . 
AltTaskKiller /IM calc.exe
if running calc.exe goto notkilled
echo Task killed . . .
pause
goto end

:notkilled
echo Task could not be killed . . . 
pause

:end

Thanks!


Solution

  • nircmd will do what you want (and much more)

    nircmd.exe killprocess calc.exe
    

    http://www.nirsoft.net/utils/nircmd.html