BAT file: Open new cmd window and execute a command in there

后端 未结 8 2147
囚心锁ツ
囚心锁ツ 2020-11-29 15:52

I\'m trying to open a new command window in a BAT file:

start %windir%\\system32\\cmd.exe

After it opens, I\'d like to execute a BAT comman

8条回答
  •  野性不改
    2020-11-29 16:27

    The above answers helped me. But still required some figuring out. Here is an example script I use to start 3 processes for web development. It results in 3 windows staying open, as they need to run continously.

    Mongo is globally added to my path, so I don't need to cd like I do for the other two programs. Of course the path to your files will vary, but hopefully this will help.

    :: Start MongoDB
    start cmd.exe /k "mongod"
    
    :: cd app directory, and start it
    cd my-app
    start cmd.exe /k "npm run dev"
    
    :: cd to api server, and start that
    cd ../my-app-api
    start cmd.exe /k "npm run dev"
    

提交回复
热议问题