通过批处理文件打开多个 Visual Studio Code 实例

huangapple go评论50阅读模式
英文:

opening multiple instances of VS Code via batch file

问题

我创建了一个批处理文件来打开VS Code到特定的文件夹。以下是代码部分 -

cd z:\files\development\xampp\code\htdocs\Acme1
code .

请注意,Z: 映射到外部SSD。
上述代码按预期工作。

然后我添加了更多的行来尝试打开多个实例的VS Code -

cd z:\files\development\xampp\code\htdocs\Acme1
code .
cd z:\files\development\xampp\code\htdocs\Acme2
code .

我期望这将打开两个独立的VS Code实例,一个打开Acme1文件夹,另一个打开Acme2文件夹。然而,它只打开了一个VS Code实例,Acme1文件夹已打开。

根据这个回答,我修改了我的Windows 11 Path环境变量以包括C:\Users\knot22\AppData\Local\Programs\Microsoft VS Code\bin。然而,即使重新启动计算机,这也没有改变批处理文件的行为。

需要做哪些更改才能让批处理文件打开两个VS Code实例呢?

英文:

I created a batch file to open VS Code to a specific folder. Here is the code -

cd z:\files\development\xampp\code\htdocs\Acme1
code .

Note that Z: maps to an external SSD.
The above works as expected.

Then I added more lines to try and open multiple instances of VS Code -

cd z:\files\development\xampp\code\htdocs\Acme1
code .
cd z:\files\development\xampp\code\htdocs\Acme2
code .

I expected this to open 2 separate instances of VS Code, one with the Acme1 folder open, the other with the Acme2 folder open. However, it only opens VS Code once, with the Acme1 folder open.

Per this answer, I modified my Windows 11 Path environment variable to include C:\Users\knot22\AppData\Local\Programs\Microsoft VS Code\bin. Alas, this made no difference in the behavior of the batch file, even after restarting the machine.

What needs to be changed to get the batch file to open both instances of VS Code?

答案1

得分: 1

这是如何使用批处理打开多个 vscode 实例的方法:

code your_first_path & code your_second_path & code your_third_path etc.

所以在你的情况下,这是如何用 vscode 打开两个文件夹的方法:

code z:\files\development\xampp\code\htdocs\Acme1 & code z:\files\development\xampp\code\htdocs\Acme2

或者,你可以使用以下方法打开多个 vscode 实例:

cmd /c code your_first_path
cmd /c code your_second_path
cmd /c code your_third_path etc.
英文:

This is how you open multiple vscode instances with batch

code your_first_path & code your_second_path & code your_third_path etc.

so in your case this is how you open both folders with vscode

code z:\files\development\xampp\code\htdocs\Acme1 & code z:\files\development\xampp\code\htdocs\Acme2

alternatively you can open multiple vscode instances this way

cmd /c code your_first_path
cmd /c code your_second_path 
cmd /c code your_third_path etc.

huangapple
  • 本文由 发表于 2023年2月6日 21:30:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75361941.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定