On my system, when I have multiple instances of word running, I only see a
single task, using either task manager or tasklist. Your script below would
find and delete the only word task in existence, killing all visible
instances.
Your approach would work for Notepad, for which each instance is a separate
task. You'd just need to have one FOR loop to count them all, and another to
delete all but one. The question is - which is the "last" one?
To close all but one specific word window would require a different
technique, but that is an area I am unfamiliar with.
/Al
"oztech" <> wrote in message
news

...
>
> I have a script which kills the Microsoft Word instances running on my
> Windows 2003 server. The problem is it kills all the instances, where as
> I want to keep the last instance or last microsoft word process as it is
> And kill the rest of the ones.
> Here is the code:
>
> FOR /F "tokens=2" %%I IN ('tasklist ^| Find "WINWORD.EXE"') DO CALL
> :windowlist %%I
> goto :EOF
> goto :EOF
> :windowlist
> echo %1
> TASKKILL /PID %1 /F
> goto :EOF
>
> How can I achieve this?
>
>
> --
> oztech
> ------------------------------------------------------------------------
> oztech's Profile: http://forums.techarena.in/members/oztech.htm
> View this thread: http://forums.techarena.in/server-scripting/1030312.htm
>
> http://forums.techarena.in
>