Demiro-FE-Architect
Demiro-FE-Architect

Reputation: 3740

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

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

Upvotes: 3

Views: 10554

Answers (3)

Shakti Singh
Shakti Singh

Reputation: 38

@echo off
echo  Welcome to Electrofixes

pause 
cd C:\Users\skshr\Desktop\medical_science 
ng serve --port 4200 --open
pause

Upvotes: 1

Bibek Gurung
Bibek Gurung

Reputation: 61

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.

Upvotes: 4

Aravind
Aravind

Reputation: 41581

Save this in a bat file

d:
cd ......
code && npm start 

In your package.json specify -o to automatically launch in browser as below

  "start": "ng serve -o -w",

Upvotes: 2

Related Questions