Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.