Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running the following command

rabbitmq-server.bat" -detached

This command runs a sewrver in the background. When I run it from a batch files - the flow stops and later commands in the batch stop running .

  1. Why?
  2. What is the best way to run those kind of commands?
  3. Running them with cmd /c does the job but I not for all of those commands
share|improve this question

This is daft behaviour that Microsoft's CMD retains for backwards compatibility all of the way back to the earliest versions of Microsoft's COMMAND. If one command script runs another command script, the first command script is cancelled.

The way to get around this is with the call built-in command. Simply prefix the command script with call. This yields the behaviour that you, and I suspect most people, expect: the calling command script resumes execution when the called command script terminates.

You can also use cmd /c, but note that that's not the same thing. call just nests command scripts within the same command interpreter. cmd /c starts up an additional new command interpreter sub-process. Changes made to variables, the working directory, open file handles, and suchlike in the sub-process won't affect its parent. Conversely, call is portable, should one be using replacement command interpreters, whereas cmd ties one to a specific command interpreter.

Further reading

  • JP Software. CALL. Take Command / TCC Help.
  • "CALL". Windows XP Command-line reference A–Z. TechNet. Microsoft corporation.
share|improve this answer

You must log in to answer this question.

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