user12463073
user12463073

Reputation:

My batch script stops execution after the code . command

Here is my simple batch script:

d:
cd D:/test_folder/test_project
start chrome -incognito http://localhost:19002
code .
expo start

the script only executes up to the code . line and then gives me a prompt. expo start is never run. What could be the problem? How can I continue the execution after the code . line?

EDIT: If I remove the code . line, the file works as intended.

Upvotes: 1

Views: 1413

Answers (3)

Leonardo Merino
Leonardo Merino

Reputation: 31

You should use call:

call code .

The file run by "code ." is not really an executable but a .cmd/.bat. As discused in here. Running one batch file within another without call will stop execution.

Upvotes: 2

NdFeB
NdFeB

Reputation: 121

The answer of VaibhavJoshi almost worked for me: a new cmd is started before the script ends, and I don't want this.

On my side, where code yields two results:

C:\> where code
C:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\bin\code
C:\Users\MyUser\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd

To prevent a new cmd to be started on start "" code, I had to use the .exe directly:

set vscode="%localappdata%\Programs\Microsoft VS Code\Code.exe"

rem some other stuff ...

start "" %vscode% --folder-uri vscode-remote://ssh-remote+10.3.3.3/path/to/my/project

Worked like a charm, for local and remote projects.

Upvotes: 0

user12463073
user12463073

Reputation:

After going through a lot of posts, I found out that the way to open vs code is:

d:
cd D:/test_folder/test_project
start chrome -incognito http://localhost:19002
start "" code D:/test_folder/test_project
expo start

This works as required.

Upvotes: 2

Related Questions