Opening project in VSCode using batch file

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.
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.
What is
code
? a program?– aschipfl
Jul 2 at 9:15