Opening project in VSCode using batch file

Multi tool use
Multi tool use


Opening project in VSCode using batch file



Disclaimer: I read this and this before, but it doesn't work as I want.



Description: I decided to create set of batch files for convenient way to run different projects in VSCode from desktop in one click(double-click). I want close cmd terminal after running a batch file, but terminal remains. I tried:


start code "C:UsersMyUserNamepathtomyprojectdirectory"



and


cmd /c start code "C:UsersMyUserNamepathtomyprojectdirectory"



It quickly runs command, runs code and opens my project, then, it seems to me, closes terminal and runs a new one in desktop directory.





What is code? a program?
– aschipfl
Jul 2 at 9:15


code





Start uses the first argument in quotes as the window title. So insert a dummy pair start "" code "C:UssersMyUserNamepathtomyprojectdirectory" @aschipfl code is a batch in the path C:Program FilesMicrosoft VS Codebincode.cmd
– LotPings
Jul 2 at 9:35


start "" code "C:UssersMyUserNamepathtomyprojectdirectory"


C:Program FilesMicrosoft VS Codebincode.cmd





@LotPings, I tried it, but result is the same, excepting the terminal's title. Now it is empty.
– digizard
Jul 2 at 9:48





cmd /c start "" /d "C:UsersMyUserNamepathtomyprojectdirectory" code
– DavidPostill
Jul 2 at 10:20


cmd /c start "" /d "C:UsersMyUserNamepathtomyprojectdirectory" code





@DavidPostill thank you, but Code was opened with default empty project, and terminal remained opened in my project directory.
– digizard
Jul 2 at 10:29





1 Answer
1



I found solution with help of DavidPostill. This works fine for me:


start "" cmd /b /c code "C:UsersMyUserNamepathtomyprojectdirectory" && exit 0






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

n Kh,VXny4t,R,A9ogGhtGrotD3gN8J0w LcXXyL,wzEdCSO4P0rWT7 w0vk aqEmdRipwLN1U 7hzemd4AzLroz
WZr38 c8hInqzCBXSkE,Qj65B kYOfbQkkMjlHa4PiHZ727o

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications