When I launch the "code" command (VS Code) with optional arguments (CLI options), from Cmd (or any other CLI) it opens VS Code instead of giving me the awaited result.
For ex. if I type "code -v", or "code --version", instead of telling me the version, it opens VS Code. Same if I type "code -h" or "code --help". (Appart from that, everything is working fine, for ex. if I type "code .", or "code bogus.txt".)
I am on Windows 10, with Vs Code installed in portable mode. Of course the directory in which I installed Vs Code is in my Path environment variable.
I resarched some answers but couldn't find anybody that documented the same problem I am facing.
Most probably there is a wrong folder set in the %path%
; like:
C:\apps\VSCode
That's surprisingly incorrect (1): we are supposed to use the \bin
one, i.e. to have
C:\apps\VSCode\bin
in there instead. It is quite sunken in the docs:
[…] installations should add the VS Code binaries location to your system path. If this isn't the case, you can manually add the location to the Path environment variable […]. For example, on Windows, the default VS Code binaries location is
[%appdata%]\Local\Programs\Microsoft VS Code\bin
.
-- https://code.visualstudio.com/docs/editor/command-line#_launching-from-command-line
So try whether your ..\bin\code.cmd --version
works correctly and then adjust the %path%
accordingly, so where code
would give you
C:\apps\VSCode\bin\code
C:\apps\VSCode\bin\code.cmd