这是我的简单批处理脚本:
d:
cd D:/test_folder/test_project
start chrome -incognito http://localhost:19002
code .
expo start
脚本只执行到
code .
行,然后给我一个提示。世博会开始永远不会运行。可能是什么问题呢?我怎样才能在code .
行之后继续执行?
编辑: 如果我删除
code .
行,该文件将按预期工作。
翻了很多帖子,发现vs code的打开方式是:
d:
cd D:/test_folder/test_project
start chrome -incognito http://localhost:19002
start "" code D:/test_folder/test_project
expo start
这按要求工作。
VaibhavJoshi 的回答几乎对我有用:在脚本结束之前开始一个新的
cmd
,我不想要这个。
在我这边,
where code
产生两个结果:
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
为了防止在
cmd
开始新的start "" code
,我不得不直接使用.exe
:
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
为本地和远程项目工作得很好。
你应该使用call:
call code .
“代码”运行的文件。实际上不是可执行文件,而是 .cmd/.bat。如 here 中所述。在没有 call 的情况下在另一个批处理文件中运行一个批处理文件将停止执行。