Skip to main content

Creating a WSL Context Menu in Windows 11

·647 words

How to add an Open WSL here context menu in Windows 11
#

In this blog post I will explain how I added an ‘Open WSL here’ context menu in Windows 11.

'Open WSL here' context menu screenshot
Screenshot of Windows Explorer ‘Open WSL here’ context menu option

TL;DR Solution:
#

  1. Find your wt.exe path

    (Get-Command wt.exe).Source
    

    For me it returned something like:

    C:\Users\ray\AppData\Local\Microsoft\WindowsApps\wt.exe
    
  2. Create the per-user registry key

    1. Open Regedit.

    2. Go to (or create) these keys under your user hive (HKEY_CURRENT_USER):

      HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\WSL
      
    3. Under WSL, make a command sub-key.

    4. Select command, double-click (Default), and set it to:

      "C:\Users\ray\AppData\Local\Microsoft\WindowsApps\wt.exe" -p "Ubuntu 24.04.1 LTS" -d "%V"
      
    5. Close Regedit, then restart Explorer or log out and back in.

  3. (Optional) Add an icon

    1. Navigate to the same key we in we used in step 2.2:

      HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\WSL
      
    2. Right-click the right panel -> New -> String Value

    3. Name it “Icon”

    4. Right-click on “Icon” and select “Modify”

    5. Enter the path to your desired .ico. E.g. I made a directory at C:\Users\<USERNAME>\WindowsTerminalIcons containing a file called ubuntu.ico which I generated by finding a .png of the Ubuntu logo and then finding a png to ico converter online. So I entered C:\Users\<USERNAME>\WindowsTerminalIcons\ubuntu.ico.


Things I tried / common pitfalls
#

Environment details
#

To give some context: I’m on Windows 11, and I installed Windows Terminal from the Microsoft Store. That means wt.exe is really just an alias in:

C:\Users\<you>\AppData\Local\Microsoft\WindowsApps\wt.exe

If I had installed Windows Terminal by downloading the executable installer the traditional way from the Microsoft website, I’d have a real binary at C:\Program Files\Windows Terminal\wt.exe and none of the alias drama below would have been an issue.

Tip: Before beginning, check if you can open Windows Terminal by pressing Win + R, typing wt.exe, and hitting Enter. If it doesn’t launch, read on.

Why I worked under HKEY_CURRENT_USER instead of HKEY_CLASSES_ROOT
#

I first tried editing the key I found in the screenshot under:

HKEY_CLASSES_ROOT\Directory\Background\shell\WSL\command

But I got an “access denied” message. By consulting ChatGPT, I learned that anything I put under:

HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\WSL

would override the global settings in HKEY_CLASSES_ROOT. And since that HKEY_CURRENT_USER path belongs to me, I could edit it without admin rights.

Picking the right placeholder: %V vs %1
#

When Explorer runs my command, it replaces:

  • %V → the folder path when I right-click the background of a folder window
  • %1 → the path when I right-click the folder icon itself

I wanted the menu item on the empty space (background), so I used %V to pass the directory path into my wt.exe call.

The console host vs Windows Terminal
#

My first working command was:

wsl.exe -d Ubuntu-24.04 --cd "%V"

That dropped me into Ubuntu-24.04 correctly, but in the old console host, so the tab title stayed “cmd”.

Next, I changed it to:

wt.exe -p "Ubuntu 24.04.1 LTS" -d "%V"

From PowerShell or cmd, that launched Windows Terminal with the right tab title. But when I clicked the context menu entry, nothing happened. No error, no window—just silence. This confirmed that the Store alias wt.exe wasn’t resolving in Explorer.

Quick experiments
#

  • cmd.exe /c start "" wt ... worked but flashed a brief cmd window.
  • Direct wt.exe worked in shells but hung or failed in Explorer and Run.
  • Using the real binary path fixed everything—no flashes, no hangs.

Final fix: use the real WT binary
#

I ran (Get-Command wt.exe).Source to get the full path to the real EXE, then updated my HKEY_CURRENT_USER registry entry to:

"C:\Users\ray\AppData\Local\Microsoft\WindowsApps\wt.exe" -p "Ubuntu 24.04.1 LTS" -d "%V"

After restarting Explorer, Shift + Right-Click on any folder background and choosing Open WSL here fires up Windows Terminal directly into Ubuntu-24.04, with the proper tab title and no extra console windows.


Summary highlights:

  • Check your alias: Win + R → wt.exe
  • Override global registry by editing HKEY_CURRENT_USER\Software\Classes
  • Use %V for background clicks
  • Find the real wt.exe path with (Get-Command wt.exe).Source
  • Point your context-menu command at that full path for a clean launch