Windows start /wait /b NOT working

26,393

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.)

Share:
26,393

Related videos on Youtube

martineau
Author by

martineau

Most of my interest and expertise is in software written in Python and C/C++. I've been writing computer code most of my adult life, beginning my senior year in high school working at a part-time NASA job utilizing a CDC 7600 (generally regarded as the fastest supercomputer in the world at the time), punched cards, and FORTRAN IV, soon followed by a mixture of Applesoft BASIC and 6502 assembler on a 64K Apple II personal computer purchased while attending college in California. I currently live in the state of Washington in the USA, at the base of the western foothills of the Cascade mountains, near a small town named Enumclaw, which lies south of Seattle and east of Tacoma. NOTE: Please don't contact me via LinkedIn to ask to be added to my network.

Updated on September 18, 2022

Comments

  • martineau
    martineau almost 2 years

    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.

    • Admin
      Admin over 12 years
      Seems to be working in Windows 7. Could you us give the OS Version and application name?
  • jon Z
    jon Z over 12 years
    I'm getting the same results here. The waiting I was referring to earlier was the pause after executing start /wait /b schtasks.exe.
  • Andrew
    Andrew over 6 years
    Perfect! It works!
  • martineau
    martineau about 4 years
    Doesn't work for me (either way) on Windows 7. I think it depends on what mycommand is…
  • Harry Johnston
    Harry Johnston about 4 years
    @martineau, some executables launch a sub-process and then exit. That case is outside of the scope of this question.
  • martineau
    martineau about 4 years
    Harry: Yes, I am aware of the reason why — I'm looking for a workaround for that scenario (and think one probably exists).
  • Harry Johnston
    Harry Johnston about 4 years
    @martineau, pretty sure I remember at least one question about this somewhere on SE, but I'm having trouble finding it. I don't think there are any very good solutions from the command line though, you need to write code to do the job properly.
  • martineau
    martineau about 4 years
    I just found one with an answer that looks promising — but it's really a hack.
  • Harry Johnston
    Harry Johnston about 4 years
    @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.