Search code examples
windowsbatch-filetomcatcmdmaven-cargo

Close cmd after launching a server with batch


What Im trying to do is to close the cmd after running a cargo tomcat server through a batch script.. I've tried attempts such as;

  • start mvn -P cargo.run && exit

  • start "" mvn -P cargo.run exit

  • start "" mvn -P cargo.run -Drepo.path=storage exit /b

none of them seems to work, and the cmd is still staying open. As seen in the SS.

Anyone who might know how it could be done?

[ScreenShot]

  • OS windows 7

Solution

  • what you try, is like (start ... ) && exit. You need start (... & exit) (logical notation, will not work like this).

    You have to escape the & to be passed to the new instance:

    start mvn -P cargo.run ^& exit
    

    If you need &&, escape both of them:

    start mvn -P cargo.run ^&^& exit
    

    (& = "and then", && = "if previous command was successful, then")