At work, there is an enterprise security policy where all executables are only allowed to run out of C:\Program Files
or C:\Program Files (x86)
.
In Visual Studio Code, in settings.json
, using the following settings:
{ "terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe", "terminal.integrated.shellArgs.windows": [ "/k C:\\Program Files (x86)\\Cmder\\vendor\\init.bat" ] }
...on initialization for the integrated terminal, I receive the following error message:
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Because of Windows' awesome file/directory naming convention allowing spaces, it is difficult to point to one of the Program File
paths.
VSCode doesn't like it when you escape the space character, and this code gives me the error Invalid escape character in string
. When I try to change the property to this:
{ ... "terminal.integrated.shellArgs.windows": [ "/k C:\\Program\ Files\ (x86)\\Cmder\\vendor\\init.bat" ] }
...I get the following error message:
'C:\ProgramFiles' is not recognized as an internal or external command, operable program or batch file.
Lastly, trying to surround the path in quotes like this:
{ ... "terminal.integrated.shellArgs.windows": [ "/k \"C:\\Program Files (x86)\\Cmder\\vendor\\init.bat\"" ] }
...gives me this error message:
'\"C:\Program Files (x86)\Cmder\vendor\init.bat\""' is not recognized as an internal or external command, operable program or batch file.
Is there any way to integrate Cmder in VSCode?
Open up Powershell profile by writing. Now, to add it to visual studio code. Open VSCode, go to Terminal, new terminal, then under the plus icon... select "Select Default Shell" and pick the one you want to use.
Setting Cmder settings Now jump through a few steps: On the left-hand side, look under Startup and click Tasks. Select {cmd::Cmder} on the left hand side. Check the box for Default task for new console.
After scouring the Internet for answers, I couldn't find a solution, but I figured it out and thought I might post it here for others to see, as I've seen that people from different forums had the same question but there was no answer.
In Windows, there is a /X
for the dir
command, which states:
/X This displays the short names generated for non-8dot3 file names. The format is that of /N with the short name inserted before the long name. If no short name is present, blanks are displayed in its place.
So, doing a dir /X
command on C:\
displays the following:
C:\>dir /X Volume in drive C is OSDisk Volume Serial Number is XXXX-XXXX Directory of C:\ ... 08/17/2017 08:02 PM <DIR> PROGRA~1 Program Files 08/09/2017 03:58 PM <DIR> PROGRA~2 Program Files (x86) ...
You can use the directory short name PROGRA~2
to substitute Program Files (x86)
, and have the following settings in your settings.json
for VS Code:
{ "terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe", "terminal.integrated.shellArgs.windows": [ "/k C:\\PROGRA~2\\Cmder\\vendor\\init.bat" ] }
Which does load Cmder successfully in the integrated terminal:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With