Angular – Running a set of commands from a batch file (run VSCode, run NG serve)

angularbatch-filevisual-studio-code

OK, so I want to run my whole working environment from a batch file…

what I would like to achieve…

  1. Open new powershell, open my API folder and run VS Code editor from that folder (cd c:\xy; code .)
  2. Run API express server (node .)
  3. Open new powershell, Change dir to my angular cli app and run the vscode there (cd c:\xy-app; code .)
  4. Run ng serve
  5. open chrome on http://localhost:4200 after ng serve is done

Hope it makes sense…
I tried this in my run-work.bat

cd C:\xy
code .
node .
cd C:\xy-app
code .
ng serve

it stops after running the first code . so the node . does not get executed

any ideas?

I want to run all commands listed in succession! Possibly terminating in 5 windows open…. powershell 1 (with node server running) powershell 2 (with angular app running) vscode 1 (with API app), vscode 2 (with Angular app) and a chrome window

Best Answer

Try this:

start /min cmd /c "cd C:\{path to angular project} && code . && ng serve --port 4200 --open"
start /min cmd /c "cd C:\{path to express project} && code . && npm run dev"

/min to open cmd minimized. This will open 4 windows i.e a cmd with angular app, a cmd with node server, a vs code with angular app and a vs code with api app.

--open after ng serve with open browser after it has finished building.