I am trying to write a powershell script that would load up my workspace.

I would like to open VSCode from the script as well, I have learnt that this can be achieves by simply running the VSCode executable with the argument of the file/directory I would like to open.

PS > code <dir>

However, doing so yields two VSCode windows to open, one with <dir> and one with previously open tabs. Are there any command-line tags I can give to force VSCode to only open <dir> and not the other window?

1 Answer 1


PowerShell is not the solution, as it cannot control VSCode.

The default setting of Visual Studio Code is to open a new instance of every file it opens externally on its application,

If you are looking to force only one single instance of VS Code during runtime, you need to set in the file settings.json the configuration key window.openFilesInNewWindow to off, like this:

"workbench.colorTheme": "Monokai Dimmed",
"window.openFilesInNewWindow": "off"

Alternatively, you may open the files internally in VSCode using the Command line interface (CLI). You might also find useful an extension such as Macros to automate these operations.

  • It defaults to off. Also by workspace I meant other programs and services to open and load, not referring to the VSCode workspace, sorry for the ambiguity.
    – Salim
    Jul 19, 2019 at 8:11
  • For this kind of complex operations, I would either use a macro interface such as in the answer, or a full macro recorder such as AutoHotkey.
    – harrymc
    Jul 19, 2019 at 8:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .