Skip to main content

Adding Context Menu Item for Windows Terminal To File Explorer

The new Windows terminal is a huge improvement over the traditional Command Prompt and Powershell. In this post I'll explain how to create a context menu shortcut 'Open Terminal Here' which appears when you right click in File Explorer. For this we will be editing the system registry so make sure you follow these steps exactly as accidently changing something in the registry can have serious consequences.

I will assume you have installed the latest preview version of Windows Terminal from the Windows Store.


Normally shells provide a command line argument when they start which you can use to specify the folder they should open to. However, Windows Terminal is still in Preview so doesn't have this yet. We will use a work-around which has a small side effect: when you open Windows Terminal by another means, (e.g. through the start menu) it will open to the Windows system folder (rather than the standard user account folder). I don't have a fix for this yet but there will definitely be one by the time Windows Terminal comes out of preview.

Step 1: Find the file path to Windows Terminal

Open file explorer and enter the following into the address bar:

Hopefully this folder will contain a file called "wt.exe". This file will open up Windows Terminal. It's a good idea to check this works by double clicking on it.

You'll need to remember the path to this file for later. An easy way to get the path is by selecting the file in File Explorer and clicking "Copy path" option on the ribbon.

If you don't find the file here there are a few things you should check:
1. Try typing 'wt' into command prompt. If this doesn't open Windows Terminal, it probably hasn't been installed correctly so try reinstalling it.
2. If typing 'wt' did work then it means the file 'wt.exe' has been added to your system's PATH environment variable. Open up Windows environment variables by typing 'Environment Variables' into Windows Search and select "Edit the system environment variables" option. Then in the window that appears select "Environment Variables".
3. Then select the "Path" environment variable from the list. A list of folders should appear. Check all of these folders until you find the one containing "wt.exe", then use this path to the file.

Step 2: Open Registry Editor

Press the Windows key (on your keyboard) and the 'R' key at the same time, to open the 'Run' app. Type in 'regedit' and press 'OK' (it will then ask for admin permissions).
Then within the registry editor navigate to the following folder:

This assumes you want to add it to all user accounts as an administrator, if just for a single user account use the following folder instead: HKEY_CURRENT_USER\Software\Classes\directory\Background\shell

Step 3: Add the context menu item

Within the shell folder, right click and select "New > Key". Name the key something like "win_terminal". Then with the "win_terminal" key selected double click double click on the "Default" key. Enter the value "Open Terminal Here" or whatever you want the context menu item to say.

Now in the left hand panel right click on "win_terminal" and select "New > Key", this time call it "command". Then select the created "command" key and double click on the "Default" key. Set the value of the key to the path you found in step 1, surrounded by speech marks. For example, on my system I used the following:

Step 4: Add an Icon

When you right click in File Explorer, it would be nice if our "Open Terminal Here" option had the Windows Terminal icon next to it. This is easy to add. First download the Windows Terminal icon as a .ico file from the official GitHub repository here. You will need to save it somewhere, where it will need to live permanently.

Then in the Registry Editor select the "win_terminal" folder we created. Then in the main area of the editor, right click and select "New > String Value". Give the key the name "Icon" and the value should the path to the ".ico" icon file.

You can use any .ico file you want for this or even create your own (there are lots of handy online tools that can convert a .png to .ico).

Step 5: Set Startup Folder

You should notice the context meu item was working since the end of step 3. But it opens Windows Terminal to the default working directory, not the same directory file explorer is in. As I mentioned in the disclaimer, there is not currently a perfect solution to this since Windows Terminal doesn't have the right command line options yet. However, we can fix this another way.

Open Windows Terminal and select "Settings" (from the drop down arrow on the top window bar). This will open the "profiles.json" in a text editor (probably notepad) which contains Windows Terminal themes and settings for different types of shells. Under "profiles" you will notice the first profile is for PowerShell, as the name is set to "Windows Powershell". Add the following line to this profile:
"startingDirectory" : "%__CD__%"

If you save the file and try the context menu shortcut in File Explorer again, it should now open Windows Terminal to the right working directory!

All done!

Thanks for reading, I hope this was useful to you. Please leave questions or comments below.


Post a Comment

Popular posts from this blog

Terminals in Sublime Text 3

TL;DR - Need a quick answer on how to create terminals in Sublime Text 3? Scroll down and watch the video or read the instructions below it. A while ago I started a series on YouTube of 'Sublime Text Tips'. Sublime Text 3 is one the best code editors currently in existence (fact), but most people just install it an use it without realising how it can be customized and extended to meet your needs. My aim was to release a series of videos explaining some of these widely unknown capabilities. I got as far as the third video and then got distracted with other things 😅 But recently I noticed the 3rd video I made has been increasing in popularity. For at least 6 months it sat at less than 200 views, and over the course of the last 2 months it has shot up to 850 (at the time of writing). Perhaps it's coincidence, or perhaps YouTube's algorithms have changed. Either way, there seem to be people who want this information. The video explains how to set up termin

Generating a MSI Installer for a WPF Application

This post serves as a tutorial for creating a MSI installer for your WPF Applications in Visual Studio. For this we use WiX (recommended by Microsoft). Prerequisites I assume you already have a Visual Studio solution containing a WPF Project. And I assume you have some experience with Visual Studio and XML. You do not need any prior knowledge of WiX. Step 1: Install Wix We are going to need WiX to generate our MSI. If you don't already have Wix installed, go ahead and download it from here . You'll be redirected to the relevant GitHub releases page where you can download the .exe file to install WiX.

Best Packages for Sublime Text 3 (Excluding Themes)

Sublime Text 3 is pretty good out-of-the-box but reaches a whole new level when you install some of the great packages on offer. Below I'll list my favourite packages for Sublime Text. These are all packages which will enhance your productivity across all languages, so no themes or language-specific packages will be listed here.