6

Is there a way to emulate the unix cut command on windows XP, without resorting to cygwin or other non-standard windows capabilities?

Example: Use tasklist /v, find the specific task by the window title, then extract the PID from that list to pass to taskkill.

Kevin Haines
  • 2,492
  • 3
  • 18
  • 19
  • Thanks. The tokens & delims do a fair emulation of cut - just a pain to have to clutter the batch file with unrequired for loops. – Kevin Haines Sep 19 '08 at 01:45

1 Answers1

10

FYI, tasklist and taskkill already have filtering capabilities:

tasklist /FI "imagename eq chrome.exe"
taskkill /F /FI "imagename eq iexplore.exe"

If you want more general functionality, batch scripts (ugh) can help. For example:

for /f "tokens=1,2 delims= " %%i in ('tasklist /v') do (
  if "%%i" == "%~1" (
    echo TASKKILL /PID %%j
  )
)

There's a fair amount of help for the windows command-line. Type "help" to get a list of commands with a simple summary then type "help " for more information about that command (e.g. "help for").

Wedge
  • 19,513
  • 7
  • 48
  • 71