On Sep 8, 4:40*am, c...@live.com (Cindy Parker) wrote:
> From a DOS batch script under WinXP I launched another CommandPrompt and start a program "myserver" in
> this new window with a command like:
>
> START cmd.exe /k "myserver parm1 parm2"
>
> The original initiating batch script ends.
>
> Then - after a while - I start another DOS batch script and
> want to close this previously created other cmd.exe window.
>
> How can I do this?
>
> I don't want to touch the program "myserver".
> All necessary stuff should be done in the closing batch script.
> And of cause I don't want to manually enter "exit" in the CommandPrompt to be closed.
> All should be done automatically in/from a closing supervisor batch script.
>
> In other words: I need the opposite of the START command.
> Unfortunately there is no command like:
>
> CLOSE "cmd.exe -title=myserver"
>
> Is there a work around for that?
>
> Cindy
Try something like this ...
taskkill /f /fi "WINDOWTITLE eq myserver"
I believe the filter name part (WINDOWTITLE) is case sensitive. I
don't think any of the rest of it is, but you can test that part.
BTW, this does not cause an orderly shutdown of the application. It
just does what the name implies - it kills it. You might also want to
look at the TaskList utility to build a confirmation test to prove
that the desired process is in fact a cmd.exe window. If there are
only two command console applications running, it will be the second
one. You could then select the PID from the second item in the
listing and use that to kill the process. (Left to the studant ;-)
_____________________
Tom Lavedas
|