Running visual studio code in the current folder with batch file

I can follow below sequence of actions to run the Visual Studio Code in the current folder.

select the location bar in the current folder and run (ALT + D):

cmd /k code .

I've tried to wrap the code . in the batch file (and place it in a folder where is declared in the PATH variable to run it as its own), it launches "Visual Studio Code" but doesn't close the command window until i close the visual studio code.

i know "start" command need to be there with exit command in the end but so far the combinations i've tried didn't really let me achieve that.

cmd.exe /k code . exit

Any ideas?


Solution 1:

this works for me, Do not omit the first empty quote

Start "" "C:\Program Files (x86)\Microsoft VS Code\code.exe" <path_to_dir>\.

Solution 2:

This works for me (be sure to start code and exit at the bottom of the batch file):

start "" code
exit