7

Despite what the documentation says, I cannot get start /wait to work with /b, despite stabbing in the dark trying nearly every possible combination of inputs I can imagine. My command path does not contain spaces, so this is not a quoting issue.

This works:

start /wait <path-to-.exe> <param1> <param2> ...

This does NOT work:

start /wait /b <path-to-.exe> <param1> <param2> ...

The program I'm trying to run is a CLI/console application, so this caveat (from start /help) shouldn't apply:

When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt. This new behavior does NOT occur if executing within a command script.

2
  • Seems to be working in Windows 7. Could you us give the OS Version and application name?
    – jon Z
    Nov 6, 2011 at 10:16
  • @jonZ, I can reproduce the problem on a variety of systems, e.g., I've tested Windows 7 SP1 32-bit, 2008 R2 SP1 64-bit, and Windows 2003 SP2 32-bit. The start command ignores the /wait option if it is followed by /b, e.g., start /wait /b notepad won't wait. Could you test again? Nov 6, 2011 at 22:03

1 Answer 1

14

This appears to be a bug in the implementation of the start command. There's a simple workaround:

start /wait /b mycommand

doesn't work (the /wait argument is ignored) but

start /b /wait mycommand

does. (Note that in this simple example you might as well just run mycommand directly, but this workaround may be useful if you want use options such as /low or /i.)

7
  • I'm getting the same results here. The waiting I was referring to earlier was the pause after executing start /wait /b schtasks.exe.
    – jon Z
    Nov 8, 2011 at 21:52
  • Doesn't work for me (either way) on Windows 7. I think it depends on what mycommand is…
    – martineau
    May 10, 2020 at 20:43
  • @martineau, some executables launch a sub-process and then exit. That case is outside of the scope of this question. May 10, 2020 at 20:47
  • Harry: Yes, I am aware of the reason why — I'm looking for a workaround for that scenario (and think one probably exists).
    – martineau
    May 10, 2020 at 20:49
  • 1
    @martineau, here's one of the questions I was thinking of. I think I've also seen a klutzy but effective way to do this in batch, by redirecting standard output to a dummy file and then waiting until you can delete the file, which will fail until the process tree has exited. May 10, 2020 at 21:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .