Some issues running Visual Studio Code

I'm having two somewhat minor issues related to different ways of launching the same external program. In this case it is Visual Studio Code. I often find myself in a directory wanting to launch VS Code for that folder. I currently do this one of two ways:

  1. Use the FAYT bar and write ">code .". This works, but it leaves a blank cmd.exe window hanging around that I have to manually close. I'm not sure how to avoid that popping up, or at least close automatically.

  2. Go to the File menu and select the context menu item "Open with Code". For some reason this opens VS Code in "C:\Windows\System32" instead of the directory I am currently in in the lister. If I instead right click on an empty spot in the lister and select the same context menu item, it opens VS Code with the correct directory. However, I never use this option since it's less convenient. On my laptop I can't right click easily since I just use the keyboard, and I'd also have to find a blank space to right click which can be tough in a directory full of files.

If you use the Run dialog (Win+R) that's part of Windows, and run code . from there, do you also get a cmd.exe window hanging around? It sounds like Code is creating that cmd.exe for some reason.

What happens with the same menu item in File Explorer?

You can probably create an Opus button, menu item or hotkey which works correctly like so:

cd {sourcepath}
code

Or, if you want to open the selected file (if there is one):

cd {sourcepath}
code {filepath}

(This is just a guess as I don't have VS Code installed here.)

Dragging code.exe to a toolbar while in Customize mode will also give you a dialog where you can turn various options on and off to auto-generate a command, and where you can test-run the command with those options until it works as you want it to:

Opus 12 manual: Launch Options dialog

My VS Code button looks like this:

@nodeselect 
@set exeCode="%programfiles%\Microsoft VS Code\Code.exe"

// Open selected files
@keydown:none
{$exeCode} {allfilepath}

// Open current directory
@keydown:ctrl
{$exeCode} {sourcepath}

// Open link in clipboard
@keydown:ctrlshift
{$exeCode} "{clip}"

Open in VSCode.dcf (909 Bytes)

Thanks guys! Indeed, VS Code was creating the cmd window and leaving it hanging around, that never even crossed my mind to check because it's such unexpected behavior. I guess it's a side effect of it being an electron app. Perhaps the other issue is, as well. I will try the button solution for launching code, thanks!

1 Like