views:

41

answers:

1

I want to have a cmd file with something like:

:one
start /wait (blabla1.exe -q -m 1>blabla1.log 2>&1)

:two
start /wait (blabla2.exe -q -m 1>blabla2.log 2>&1)

where I want the output of the blabla application not the output of the start command.

Is it even possible to have the redirections "local" inside the start command?

Do I have to create a 1 line cmd containing
blabla1.exe -q -m 1>blabla1.log 2>&1
and pass it to the start command?

Update: I need the first one (blabla1.exe) to be finished before I launch the 2nd one (blabla2.exe). That's the reason for using start /wait.

(Windows XP and up)

+1  A: 

Given that you are redirecting output to a file, and waiting for the process to finish, is the extra window started by 'start' actually required? In fact, if there WAS some way to redirect the output when using start, then the windows that popped up wouldn't even have any output...making them even more meaningless.

If not, simply remove the "start /wait" and call the exes directly.

If it IS necessary...then I'm not sure.

UPDATE: I am fairly certain just removing the "start /wait" will produce the behavior you desire. See below:

(Create the following batch file: foo.cmd

:one
notepad.exe
:two
dir

Note that dir will not echo until you close notepad.

Joshua McKinnon
@Joshua. I need the 2nd one to start AFTER the first one has finished. So I guess I need the /wait.
François
@Francois - Right - in batch files, when you don't use start, batch files do not continue to the next line until a cmd/exe finishes. It is only when you do use start, that this /wait is necessary to wait until the first exits. Adding sample batch script to demonstrate
Joshua McKinnon
@Joshua. You're right I don't need `start` in the first place, then I don't need `/wait`. Just without, it works as I intended. Thanks! {why do it simple when you can do it complicated! sigh ;-) }
François