1

I'm trying to create a batch file that opens Visual Studio Code. I'm using this SO answer as a guide to do so. This is the command I end up with:

start "MyTitle" "C:\Program Files\Microsoft VS Code\bin\code.cmd" "C:\MyFolder"

When I run this, I see two command windows appear:

  • One window runs the command and closes immediately. I think this is right.
  • The other window is titled "MyTitle" and gives me this error message:
    • 'C:\Program' is not recognized as an internal or external command, operable program or batch file.

What am I doing wrong? Do I need to escape the spaces in that path?

I've found a lot of SO questions relating to this, and I've tried the solutions I've found, but I can't get anything to work. Here are some answers I've found and tried:

user2023861
  • 8,030
  • 9
  • 57
  • 86
  • Have you addressed the space issue first? https://stackoverflow.com/questions/18537098/spaces-cause-split-in-path-with-powershell – wannadream Nov 19 '18 at 18:28
  • 2
    The batch file `"C:\Program Files\Microsoft VS Code\bin\code.cmd"` will spawn the .exe `"C:\Program Files\Microsoft VS Code\Code.exe"` anyway and terminate, so simply **call** the batch to have it return to the batch afterwards. –  Nov 19 '18 at 18:33
  • @wannadream I'm not using Powershell. If I can't get this batch script figured out, I'll switch to Powershell. – user2023861 Nov 19 '18 at 19:15
  • @LotPings That fixed it. I dind't think to look into the *.cmd file. Now my command is `start "MyTitle" "C:\Program Files\Microsoft VS Code\Code.exe" "C:\MyFolder"` – user2023861 Nov 19 '18 at 19:23

0 Answers0