PC Review


Reply
Thread Tools Rate Thread

Closing another cmd.exe window from batch script? Opposite of START cmd.exe /k "...." ?

 
 
Cindy Parker
Guest
Posts: n/a
 
      8th Sep 2010
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

 
Reply With Quote
 
 
 
 
foxidrive
Guest
Posts: n/a
 
      8th Sep 2010
On 8/09/2010 18:40, 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?



What is myserver? A 32 bit Windows GUI or console command?

Have you tried this?


START "" "myserver" parm1 parm2



--
Regards,
Mic
 
Reply With Quote
 
Tom Lavedas
Guest
Posts: n/a
 
      8th Sep 2010
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
 
Reply With Quote
 
Todd Vargo
Guest
Posts: n/a
 
      9th Sep 2010
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?


ISTM, you left out an important piece of information or typed the command
above incorrectly. ten.nigriv provides a good work around, but, why leave
the second CMD window open in the first place? The simple solution would be
to use /c switch instead of /k switch. You could include a /wait after
START, but you did not mention the reason for opening myserver in a separate
window. I'm surprised the START command works at all with the "myserver
parm1 parm2" in quotes. First because the START command requires a window
title parameter whenever quotes are used. Second, because myserver and the
parameters are enclosed in the same pair of quotes.

--
Todd Vargo

(Post questions to group only. Remove "z" to email personal messages)

 
Reply With Quote
 
Batchman
Guest
Posts: n/a
 
      13th Sep 2010
Hi Cindy,

On Wed, 08 Sep 2010 08:40:05 +0000, Cindy Parker wrote:

> [SNIP]
> 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?
>


Have you considered using the dos CALL command to execute all but the
first batch? CALL causes another command shell to be created and a command
(batch file perhaps) to be executed, and at the end of the CALLed item the
secondary shell is automatically closed.

Batchman - I BATCH, therefore I am!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing another cmd.exe window from batch script? Opposite of START cmd.exe /k "...." ? Cindy Parker Windows XP General 2 8th Sep 2010 08:07 PM
Feature Request: "Link to record" Window should come with "push-pin"button to allow for batch linking mduijkers@gmail.com Microsoft Outlook BCM 1 4th Dec 2007 12:17 AM
Add Exchange "Contacts" to a Distirbution List with batch script? rwh@rodharrison.com Microsoft Windows 2000 Active Directory 2 16th Nov 2005 10:28 PM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM
Strange: Response.Write("<script>window.open(' ...')</script>") doesn't work on IE 5.0 Jorge_Beteta Microsoft ASP .NET 2 18th Mar 2004 01:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 PM.