Batch File Questions

L

Lushington

It's been a long time since I've done any batch programming and I need my
memory refreshed.

If I start two applications in sequence

@echo off
"C:\Program Files\My Application\My Program" /parameters
"C:\Program Files\Another App\Another Program" /parameters

Does the first program have to complete before the second one starts (which
is what I want)? Or do I have to be a little fancier?

A Command Prompt window opens when the batch file is executed. Is there a
way to close the Command Prompt window before the programs complete?
 
T

Tim Meddick

Almost right, but use the "start" command to start the programs using
the "/w" (wait) switch if you really need the first program to finish
before starting the second, thus....

@echo off
start /w "C:\Program Files\My Application\My Program" /parameters
start /w "C:\Program Files\Another App\Another Program" /parameters


==

Cheers, Tim Meddick, Peckham, London. :)
 
L

Lushington

Thanks (and to Tim Meddick too). The help file just has /wait rather than /w
but that's a small point.

And I think if I use the /B parameter, it won't open a Command Prompt
window, either.
 
T

Tim Meddick

I use the "/b" switch always (just to be on the safe side) but I think
that it really only applies to 'Command-line' tools and Win16 DOS apps.

==

Cheers, Tim Meddick, Peckham, London. :)
 
L

Lushington

Interestingly, another parameter for start is "title" which "Specifies the
title to display in Command Prompt window title bar." Even though this
parameter is supposedly optional, it seems that if the filename for the app
to be executed is enclosed in double quotes (as in my example, because of the
spaces in the path), then the start command uses the filename as the title,
doesn't find anything to execute, and completes without doing anything.

I had to use this syntax to get it to work:

start "mytitle" /wait "C:\Program Files\My Application\My Program" /parameters

and you're right, /B or no /B didn't seem to make a difference.

Start command syntax:
http://technet.microsoft.com/en-us/library/bb491005.aspx
 
T

Tim Meddick

It's probably simpler to use the "TITLE" command in a batch file to set
the title, thusly :



@echo off
title My Program
start /w /b "C:\Program Files\My Application\My Program" /parameters



.....please note - there's no need for "quotes" after the 'title'
command.


==

Cheers, Tim Meddick, Peckham, London. :)
 
G

Guest

If putting the program in quotes you have to specify a title because the
first set of quotes is taken as the title.
 
T

Terry R.

The date and time was Tuesday, June 30, 2009 7:33:59 PM, and on a whim,
pounded out on the keyboard:
If putting the program in quotes you have to specify a title because the
first set of quotes is taken as the title.

You don't have to "specify" a title. Just add an extra set of quotes.
start "" /wait "C:\Program Files\My Application\My Program" /parameters


Terry R.
 
T

Terry R.

The date and time was Tuesday, June 30, 2009 6:23:24 PM, and on a whim,
Tim Meddick pounded out on the keyboard:
It's probably simpler to use the "TITLE" command in a batch file to set
the title, thusly :



@echo off
title My Program
start /w /b "C:\Program Files\My Application\My Program" /parameters



....please note - there's no need for "quotes" after the 'title'
command.


==

Cheers, Tim Meddick, Peckham, London. :)

Tim,

You have to add the title quotes, even if they are dummies:
start "" /w /b "C:\Program Files\My Application\My Program" /parameters

otherwise what is between the quotes is interpreted as the title.

Terry R.
 
T

Terry R.

The date and time was Tuesday, June 30, 2009 7:54:31 PM, and on a whim,
pounded out on the keyboard:
Tim's example wom't work. You'll see in my post I use a blank title.

Yes, I've learned from experience... ;-)


Terry R.
 
T

Tim Meddick

I am talking about the TITLE command in cmd.exe not setting the 'title'
in a 'start' command.

It does work.

first line in a batch file :

@echo off
TITLE Tim's Command Prompt
echo.
echo The rest of your batch-stuff...
echo.
pause

I use it ALL THE TIME....

==

Cheers, Tim Meddick, Peckham, London. :)
 
G

Guest

But your Start command doesn't work.

--
..
--
Tim Meddick said:
I am talking about the TITLE command in cmd.exe not setting the 'title' in
a 'start' command.

It does work.

first line in a batch file :

@echo off
TITLE Tim's Command Prompt
echo.
echo The rest of your batch-stuff...
echo.
pause

I use it ALL THE TIME....

==

Cheers, Tim Meddick, Peckham, London. :)
 
T

Tim Meddick

Which "your start command doesn't work" ?

The one I quoted :

@echo off
title My Program
start /w /b "C:\Program Files\My Application\My Program" /parameters

???

I'm not surprised - the folder and program names are fictional and were
copied from the OP's

....then by only changing the names to valid ones thus :

I have just spotted something - very sorry - I put the '/w' and 'b'
switches the wrong way round.

@echo off
title My Notepad Program
start /b /w C:\WINDOWS\system32\notepad.exe
pause

....*will* work.

(I added the 'pause' so you can see that it really is waiting for the
Notepad program to exit...)

==

Cheers, Tim Meddick, Peckham, London. :)




But your Start command doesn't work.
 
G

Guest

Do you read anything?

Your command is faulty because the first set of inverted commas (quotes) is
taken as the title. Therefore there is no program to execute.
 
T

Tim Meddick

I understand what you mean now, and yes you are totally correct about
the quotes.

(However, I was trying to convey the use of the title command after all)

I personally have never had need to use quotes as I have always used the
DOS~ short names for the target of the start command.

Also, I never used the "title" in a start command either as I have
always used the TITLE command separately.

I am sorry for any confusion I may have caused...

==

Cheers, Tim Meddick, Peckham, London. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top