How to Manually Add “Open with VS Code” to the Windows Context Menu
Updated February 2026 — Windows 11 24H2 & Windows 10 Compatible
During the installation of Visual Studio Code (VS Code), the setup wizard provides convenient checkboxes to add “Open with Code” actions to your Windows Explorer context menu. But what happens if you forgot to check those boxes? What if you are using a portable version of VS Code? Or what if you want to add this exact functionality for a completely different code editor like Sublime Text, Cursor, or Notepad++?
You do not need to reinstall your software just to get these right-click options back. In this comprehensive technical guide, we will teach you exactly how the Windows Registry handles context menu commands and provide step-by-step instructions to manually add “Open with VS Code” to any file or folder.
Understanding Windows Registry Context Menus
Before we begin hacking the registry, it helps to understand where Windows looks for context menu items. Unlike modern packaged shell extensions (which require complex COM programming and MSIX manifests), you can add simple command-line executions to the context menu using purely static registry keys.
Windows divides the context menu based on what you are clicking on. The three most common targets are:
- Files (
*): Triggers when you right-click any single file (e.g.,index.html,script.py). - Directories (
Directory): Triggers when you right-click a folder icon. - Directory Background (
Directory\Background): Triggers when you right-click the empty white space inside an open folder.
To recreate the native VS Code experience, we need to add registry keys to all three of these locations.
⚠️ Registry Editing Warning: Modifying the Windows Registry incorrectly can cause system instability. Always back up your registry or create a System Restore point before proceeding. The instructions below are safe if followed exactly.
Step 1: Adding “Open with Code” for Right-Clicking Files
This first step ensures that when you right-click a specific file (like a .txt or .js file), you see an option to open it immediately in VS Code.
Locating Your VS Code Path
First, you need the exact path to your Code.exe application.
- System Installer (Typical):
C:\Program Files\Microsoft VS Code\Code.exe - User Installer:
C:\Users\[YourUsername]\AppData\Local\Programs\Microsoft VS Code\Code.exe
(Note: In the examples below, we will use the System Installer path. If your path is different, replace it accordingly).
Modifying the Registry
- Press
Win + R, typeregedit, and press Enter to open the Registry Editor. - Navigate to the following path:
HKEY_CLASSES_ROOT\*\shell - Right-click the
shellfolder, select New > Key, and name itVSCode. (This is the internal name, not what displays on the menu). - Click on your new
VSCodefolder. In the right pane, double-click the (Default) string value and change its Value Data to:Open with Code(This is the text that will actually appear in your right-click menu).
Adding the Icon
To make it look professional, let’s add the VS Code icon.
- Right-click the
VSCodefolder again -> New > String Value. - Name the value exactly
Icon. - Double-click
Iconand set its Value Data to the path of your executable:"C:\Program Files\Microsoft VS Code\Code.exe"
Adding the Command Execution
Finally, we must tell Windows what to do when you click the button.
- Right-click the
VSCodefolder -> New > Key, and name itcommand. - Click the new
commandfolder. In the right pane, double-click the (Default) string value. - Set the Value Data to:
"C:\Program Files\Microsoft VS Code\Code.exe" "%1"(The%1is a Windows variable that passes the path of the file you right-clicked directly to VS Code).
Test it: Right-click any file on your desktop. You should immediately see the “Open with Code” option with the corresponding icon.
Step 2: Adding “Open with Code” for Right-Clicking Folders
Opening individual files is great, but developers usually want to open entire project directories as workspaces. This step adds the option when you right-click a folder icon.
- In the Registry Editor, navigate to:
HKEY_CLASSES_ROOT\Directory\shell - Right-click the
shellfolder -> New > Key, and name itVSCode. - Change the (Default) value to:
Open with Code - Create a New > String Value named
Iconand set it to:"C:\Program Files\Microsoft VS Code\Code.exe" - Right-click the
VSCodefolder -> New > Key -> name itcommand. - Change the
command(Default) value to:"C:\Program Files\Microsoft VS Code\Code.exe" "%1"
Step 3: Adding “Open with Code” to the Folder Background
Perhaps the most useful variation is the ability to open your current folder by right-clicking the empty space in the Explorer window.
- Navigate to:
HKEY_CLASSES_ROOT\Directory\Background\shell - Right-click
shell-> New > Key, name itVSCode. - Change (Default) to:
Open with Code - Create the
Iconstring value:"C:\Program Files\Microsoft VS Code\Code.exe" - Right-click
VSCode-> New > Key -> name itcommand. - Change the
command(Default) value to:"C:\Program Files\Microsoft VS Code\Code.exe" "%V"(Note: Notice the use of%Vhere instead of%1.%Vrepresents the current working directory, which is essential for folder backgrounds).
Automating the Process (The .REG File Method)
If editing the registry manually seems tedious or risky, you can automate exactly what we just did using a Registry Script (.reg file). This is highly recommended for IT admins setting up multiple developer machines.
- Open Notepad.
- Copy and paste the following text block exactly as written. (Ensure the paths match your VS Code installation location!)
Windows Registry Editor Version 5.00
; Add to files
[HKEY_CLASSES_ROOT\*\shell\VSCode]
@="Open with Code"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\""
[HKEY_CLASSES_ROOT\*\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""
; Add to folders
[HKEY_CLASSES_ROOT\Directory\shell\VSCode]
@="Open with Code"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\""
[HKEY_CLASSES_ROOT\Directory\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""
; Add to folder backgrounds
[HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode]
@="Open with Code"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\""
[HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""
- Save the file as
Add_VSCode_Context.reg. (Make sure to change “Save as type” from Text Documents to All Files). - Double-click your newly created
.regfile and click Yes when prompted to allow changes. The keys are injected instantly.
Windows 11 Caveats: The “Show More Options” Problem
If you are using Windows 11, you will immediately notice something annoying: the newly added registry keys do not appear on the modern top-level context menu. Instead, they are relegated to the bottom of the legacy menu, accessible only by clicking “Show more options” or pressing Shift + F10.
This is intentional by Microsoft. As of Windows 11, the native OS ignores simple static registry commands for the top-level menu. Only applications packaged via MSIX or those that implement advanced, out-of-process IExplorerCommand COM handlers are granted permission to the modern menu.
Is there a workaround for Windows 11?
Without forcing your entire system to revert to the Windows 10 context menu, you cannot artificially push a simple registry command to the top tier. The official VS Code installer achieves top-level placement because Microsoft implemented an IExplorerCommand handler specifically for Windows 11 in newer versions of the installer.
If you are on Windows 11 and absolutely demand top-level integration without clicking “Show more options”, your best bet is to re-run the official VS Code installer and ensure the context menu checkboxes are ticked.
Advanced Tricks: Extending This to Other Apps
The beauty of this registry method is its universality. You can adapt these exact steps to add right-click functionality for almost any portable or standalone tool.
Example: Adding Portable Notepad++
If you keep a portable version of Notepad++ on your D:\ drive:
- Navigate to
HKEY_CLASSES_ROOT\*\shell - Create key
Notepad++and set Default toEdit with Notepad++. - Set
Iconto"D:\PortableApps\Notepad++\notepad++.exe". - In the
commandsubkey, set Default to"D:\PortableApps\Notepad++\notepad++.exe" "%1".
Example: Opening a CLI Toolkit
You can even trigger scripts instead of EXEs. For example, to pass a folder into a Python formatting script:
In the command key, set Default to cmd.exe /K python C:\scripts\format_dir.py "%1".
Summary
Manually adding “Open with VS Code” to your right-click menu is a simple but powerful exercise in understanding the Windows Registry. By adding keys to HKEY_CLASSES_ROOT\*\shell and HKEY_CLASSES_ROOT\Directory\shell, you bypass the need for installers and retain full control over how your files launch. While Windows 11 hides these manual tweaks behind a secondary layer, they remain an invaluable productivity trick for power users and developers alike.
Want more Context Menu Hacks?
Learn how to remove unwanted cloud sync providers and bloatware from your right-click menus using safe registry methods.
Discover the Best Context Menu Cleaners