Windows .bat Scripting: Open VSCODE and run npm start within the terminal

  batch-file, npm, windows

i want to create a Windows shell script that opens vscode in a given directory and executes ‘npm start’ within vs code. Is that possible? I am facing some problems, hopefully you can help me.

My Script


@echo off
set codePath=C:Usersreposource
set currrentWorkingDirectory=%cd%
set VSCODE="C:Program FilesMicrosoft VS Codecode.exe"



call:start_service_ui

GOTO :EOF
:start_service_ui
echo start service UI ...
set service_ui_path=%codePat%project1service-ui


call %VSCODE% %service_ui_path%

npm start
ENDLOCAL
GOTO:EOF

1. Problem


When I call %VSCODE% %service_ui_path%, VSCode is opening but i can see the log information there, so the terminal is blocked by the VSCode operations – how can I stop that?
The same counts for npm start

2. Problem


I want to call the npm start command within VSCode, but I want to determine this in the .bat file.
Is there any possiblity to do so? I coulndĀ“t find anything online about that.

Many thanks in advance.

Source: Windows Questions

LEAVE A COMMENT