views:

58

answers:

1

So I'm using the taskkill.exe which comes with Vista and I want it to do something especially complicated..

There are multiple instances of java.exe running, and I want it to find the one that is untitled.. so this is my command:

taskkill /IM java.exe /FI "WINDOWTITLE eq "

I also tried:

taskkill /IM java.exe /FI "WINDOWTITLE ne AutoClicker"

It doesn't work anyways... So is there anyway... to target an untitled process???

A: 

You must first find the PID of the untitled process by parsing the results of TASKLIST, and then invoke TASKKILL with the found PID.

Try the following code

@echo off
SETLOCAL enabledelayedexpansion
for /f "tokens=*" %%a in ('TASKLIST /V') do (
  set s=%%a
  set p=!s:~27,5!
  set t=!s:~152,3!
  if '!t!'=='N/A' ECHO TASKKILL /PID !p! /T
)

and after extra-careful testing, remove the ECHO

PA