Terminal: Add "open Windows terminal here" into right-click context menu

Created on 30 May 2019  ·  235Comments  ·  Source: microsoft/terminal

Add "open Windows terminal here" to right-click context menu?

We know that, for windows 7, by default when we click "shift + right click with mouse" when we enter into a folder without selecting anything, we can see the option "open command window here".

image

While for windows 10, by default when we click "shift + right click with mouse", we can see the option "open powershell window here".

So for Windows 10 (version later than 1903), how can we make the following three options available in right-click context menu?

  • open command window here
  • open powershell window here
  • open Windows terminal here

Looking forward to your reply, thanks a lot~

Area-User Interface Help Wanted Issue-Feature Product-Terminal Resolution-Fix-Committed

Most helpful comment

For the record, I think we'd prefer that the terminal automatically registers this shortcut on behalf of the user.

All 235 comments

If adding it, I think it should have one more select option in open Windows terminal here to select actually what shell to open as submenu of context menu (or like that) with the 'name' wrotted in profiles of terminal, like

  • Powershell
  • CMD
  • Ubuntu

I think this is a good feature request, and something that we'd definitely accept help from the community on.

My gut says that it'd be related to work for #689, but I don't know enough about Win32 to be sure.

This is probably something like this: https://www.codeproject.com/Articles/441/The-Complete-Idiot-s-Guide-to-Writing-Shell-Extens

But hopefully without re-introducing ATL into our codebase...

It's way, _way_ easier than that to add a single command to a folder context menu. It's just a simple registry key.

For example (and then you can also add an icon, etc)

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\Open Thing Here\command]
@="C:\\thing.exe \"%1\""

for pacakged apps this is declared in the manifest. see this: https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-filetypeassociation. I don't think this supports folders but start looking here.

Likely duplicate of #561, but we'll track it here.

@miniksa @zadjii-msft @DHowett-MSFT @factormystic @ChrisGuzak

I solved the issue now, it could be closed. Thanks a lot to all who involved into this discussion.

Step 0:

Test if two constants below works well which will be used in following other steps.

echo %USERPROFILE%

echo %LOCALAPPDATA%

If everything works well here, then these two constants can be used directly in other below steps.

Or please perform following replacements in below steps:

%USERPROFILE% → C:\Users\[userName]
%LOCALAPPDATA% → C:\Users\[userName]\AppData\Local

Here [userName] represents your user name,for instance, mine is Bruce.

Step 1:
Run below stuff in CMD:

mkdir "%USERPROFILE%\AppData\Local\terminal"

image

Step 2:
Copy the windows terminal icon to the folder %USERPROFILE%\AppData\Local\terminal, the icon can be obtained in https://github.com/yanglr/WindowsDevTools/tree/master/awosomeTerminal/icons whose file name is wt_32.ico.

Step 3:
Save follwing content as wt.reg, then run as administrator.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt_32.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"

To be noted, if the exe obtained after building code by yourself is wtd.exe, you need to change the above wt.exe to wtd.exe in the above registry.

Step 4:
Test
image

That didn't work to me (can't access to it error), and for me it was wtd.exe(didn't even work).
And I think this could be the Terminal Feature.

@SJang1
I guess you used the version you bulit yourself, so need to use wtd.exe. For incoming official version to enter into Windows Store, wt.exe is the correct option here. For now, you can obtain preview version here (.7z file under https://github.com/yanglr/WindowsDevTools/tree/master/awosomeTerminal), then use wt.exe after installed. I adopted this method.

@yanglr I have used wtd.exe, and didn't work having error of can't access to it.. However, every end-user couldn't add to registry one-by-one.

@SJang1
I guess you built the code in Debug mode, please change to Release mode, see below:
image

@yanglr
Already Built in Release.
image

For the record, I think we'd prefer that the terminal automatically registers this shortcut on behalf of the user.

@zadjii-msft
Cool, great !

This hasn't been added yet, so I'd prefer we keep this issue open till the work to add it has been done :)

Can I give this a shot if no one is working on it?

@MelulekiDube go for it!

My main tip here would be that we've been trying to keep TerminalApp more UWP-like, and doing Win32-like things in the WindowsTerminal project. Since this feature is probably fairly Win32 heavy, I'd probably suggest some sort of event that the App (in TerminalApp) can fire to notify the AppHost (in WindowsTerminal) that it should set up the shortcuts. As an example, I believe there's an event TitleChanged that the App can fire to have the AppHost set the title of the window.

Additionally, since a Profile isn't a winrt type, it might be hard to get at its members straight from the WindowsTerminal project. You might have to have the App communicate the relevant bits of the Profile in the event itself. Alternatively, you could try making it a winrt type (complete with an .idl file), but that might be a bit harder.

Good luck!

EDIT: I revise this statement to HERE BE DRAGONS. There's work that might need to get done in #607/#1065 before this can be done at all.

I'm concerned that this will need to tie in pretty closely with #607, which is still in the pre-spec phase.

@DHowett-MSFT that's a good point. I also forgot about the recent regression in #1065. This actually might fall under the category of _hard_ things. Even if we didn't do it per-profile, opening the default profile in the current directory wouldn't work.

I don't even know how we'd fix #1065, but if we did fix that, then theoretically we could find some way to create the new Windows Terminal instance using the directory from explorer, but that wouldn't really solve the per-profile issue. hmmmm.

Could something like exposing the staringDirectory so you can pass it into the exe an option?

Yes, that is part of the point in #607.

Hi @yanglr,
This isn’t the appropriate place to have that discussion. This issue is for discussing the “open Windows Terminal here” feature.

@DHowett-MSFT
Oh, sorry, deleted.

I think it would be great to have not just “open Windows Terminal here”, but also “open Windows Terminal here (Administrator)” cause both are well used by everyone.

I was thinking about like this,
image
..and if it does like what i thought, seems no place to put run as Administrator at it.

I was thinking about like this,
image
..and if it does like what i thought, seems no place to put run as Administrator at it.

... unless you put a second main menu "Open WT here (Administrator)" with the same submenu items. Both should be optional anyway, I think.

I edited the registry to add the option to the context menu. However, it opens with C:\Users\username instead of the current directory.

@minhtuanta

I'm concerned that this will need to tie in pretty closely with #607, which is still in the pre-spec phase.

Could something like exposing the staringDirectory so you can pass it into the exe an option?

Yes, that is part of the point in #607.

wt.exe doesn't support command line arguments yet, so there's no way to override what folder the new profile starts in.

if I might make a suggestion, I'd say the options to open in powershell, CMD and/or Linux terminal should be replaced by "Open in windows terminal" since the windows terminal is the combination of all three. Then a user can set his default from the profile.json file.

@yanglr @lllopo @SJang1

Something like this _should_ work for now. I wrote it in PowerShell because it's for a Post-Install Windows ISO script, but I don't see an issue with using this as opposed to a .reg file.

PowerShell:

$Env.terminalDir ='$Env:localAppDir\Microsoft\WindowsApps' # Not really needed (except for icon), as wt.exe in in %PATH%

Invoke-WebRequest -UseBasicParsing "https://github.com/yanglr/WindowsDevTools/raw/master/awosomeTerminal/icons/wt_32.ico" -OutFile "$Env:terminalDir\wt.ico"  # Going to update my own to just grab icon from the appx package

Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminal' -Name 'MUIVerb' -Type String -Value 'Terminals'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminal' -Name 'Icon' -Type String -Value '$Env:terminalDir\wt.ico'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminal' -Name 'ExtendedSubCommandsKey' -Type String -Value 'Directory\\ContextMenus\\MenuTerminal'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell\open' -Name 'MUIVerb' -Type String -Value 'PowerShell'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell\open' -Name 'Icon' -Type String -Value 'PowerShell.exe'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell\open' -Name 'ExtendedSubCommandsKey' -Type String -Value 'Directory\\ContextMenus\\MenuTerminal\\PS'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\open' -Name 'MUIVerb' -Type String -Value 'PowerShell'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\open' -Name 'Icon' -Type String -Value '$Env:terminalDir\wt.ico'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\open\command' -Name '@' -Type String -Value 'wt.exe'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\runas' -Name 'MUIVerb' -Type String -Value 'Elevated PowerShell'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\runas' -Name 'Icon' -Type String -Value '$Env:terminalDir\wt.ico'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\runas' -Name 'HasLUAShield' -Type String -Value ''
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\runas\command'-Name '@' -Type String -Value 'wt.exe'

And something like this _should_ work when one is able to choose between CMD and PowerShell when launching the Terminal (assuming it uses --Profile [CMD|PowerShell]):

Powershell:

$Env.terminalDir ='$Env:localAppDir\Microsoft\WindowsApps'   # Not really needed (except for icon), as wt.exe in in %PATH%

Invoke-WebRequest -UseBasicParsing "https://github.com/yanglr/WindowsDevTools/raw/master/awosomeTerminal/icons/wt_32.ico" -OutFile "$Env:terminalDir\wt.ico"  # Going to update my own to just grab icon from the appx package

Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminal' -Name 'MUIVerb' -Type String -Value 'Terminals'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminal' -Name 'Icon' -Type String -Value '$Env:terminalDir\wt.ico'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\Background\shell\MenuTerminal' -Name 'ExtendedSubCommandsKey' -Type String -Value 'Directory\\ContextMenus\\MenuTerminal'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell\open' -Name 'MUIVerb' -Type String -Value 'Command Prompt'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell\open' -Name 'Icon' -Type String -Value 'cmd.exe'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell\open' -Name 'ExtendedSubCommandsKey' -Type String -Value 'Directory\\ContextMenus\\MenuTerminal\\CMD'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\CMD\shell\open' -Name 'MUIVerb' -Type String -Value 'Command Prompt'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\CMD\shell\open' -Name 'Icon' -Type String -Value '$Env:terminalDir\wt.ico'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\CMD\shell\open\command' -Name '@' -Type String -Value 'wt.exe --profile CMD'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\CMD\shell\runas' -Name 'MUIVerb' -Type String -Value 'Elevated Terminal'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\CMD\shell\runas' -Name 'Icon' -Type String -Value '$Env:terminalDir\wt.ico'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\CMD\shell\runas' -Name 'HasLUAShield' -Type String -Value ''
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\CMD\shell\runas\command'-Name '@' -Type String -Value 'wt.exe --profile CMD'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell\open' -Name 'MUIVerb' -Type String -Value 'PowerShell'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell\open' -Name 'Icon' -Type String -Value 'PowerShell.exe'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\shell\open' -Name 'ExtendedSubCommandsKey' -Type String -Value 'Directory\\ContextMenus\\MenuTerminal\\PS'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\open' -Name 'MUIVerb' -Type String -Value 'PowerShell'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\open' -Name 'Icon' -Type String -Value '$Env:terminalDir\wt.ico'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\open\command' -Name '@' -Type String -Value 'wt.exe --profile PowerShell'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\runas' -Name 'MUIVerb' -Type String -Value 'Elevated PowerShell'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\runas' -Name 'Icon' -Type String -Value '$Env:terminalDir\wt.ico'
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\runas' -Name 'HasLUAShield' -Type String -Value ''
Set-ItemProperty-Path 'HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminal\PS\shell\runas\command'-Name '@' -Type String -Value 'wt.exe --Profile PowerShell'

@yanglr I followed your steps, the right-button menu appears, but when clicked, explorer.exe says "Windows cannot access the specified device, path or file. You may not have the appropriate permission to access the item." (Windows 无法访问指定的设备、路径或文件。你可能没有适当的权限访问该项目).

Running "%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe" from cmd prompt opens new terminal as expected, and I have similar setup for msys, wsl-terminal, all works fine, only windows terminal not work.

@chen-xin This is something that worked for me for the access error.
Follow the same steps as https://github.com/microsoft/terminal/issues/1060#issuecomment-497539461
But, for the wt.exe path, instead of using %LOCALAPPDATA% , use actual full path like C:\\Users\\[your_user_acc]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe.

Also, do not add startingDirectory in settings.

@saisandeepvaddi It worked on fullpath, thank you!

@miniksa @zadjii-msft @DHowett-MSFT @factormystic @ChrisGuzak

I solved the issue now, it could be closed. Thanks a lot to all who involved into this discussion.

Step 0:

Test if two constants below works well which will be used in following other steps.

echo %USERPROFILE%

echo %LOCALAPPDATA%

If everything works well here, then these two constants can be used directly in other below steps.

Or please perform following replacements in below steps:

%USERPROFILE% → C:\Users\[userName]
%LOCALAPPDATA% → C:\Users\[userName]\AppData\Local

Here [userName] represents your user name,for instance, mine is Bruce.

Step 1:
Run below stuff in CMD:

mkdir "%USERPROFILE%\AppData\Local\terminal"

image

Step 2:
Copy the windows terminal icon to the folder %USERPROFILE%\AppData\Local\terminal, the icon can be obtained in https://github.com/yanglr/WindowsDevTools/tree/master/awosomeTerminal/icons whose file name is wt_32.ico.

Step 3:
Save follwing content as wt.reg, then run as administrator.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt_32.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"

To be noted, if the exe obtained after building code by yourself is wtd.exe, you need to change the above wt.exe to wtd.exe in the above registry.

Step 4:
Test
image

image

I have followed your instruction but this error occurs everywhere I start _Windows terminal here_

@miniksa @zadjii-msft @DHowett-MSFT @factormystic @ChrisGuzak
I solved the issue now, it could be closed. Thanks a lot to all who involved into this discussion.
Step 0:
Test if two constants below works well which will be used in following other steps.

echo %USERPROFILE%

echo %LOCALAPPDATA%

If everything works well here, then these two constants can be used directly in other below steps.
Or please perform following replacements in below steps:
%USERPROFILE% → C:\Users\[userName]
%LOCALAPPDATA% → C:\Users\[userName]\AppData\Local
Here [userName] represents your user name,for instance, mine is Bruce.
Step 1:
Run below stuff in CMD:

mkdir "%USERPROFILE%\AppData\Local\terminal"

image
Step 2:
Copy the windows terminal icon to the folder %USERPROFILE%\AppData\Local\terminal, the icon can be obtained in https://github.com/yanglr/WindowsDevTools/tree/master/awosomeTerminal/icons whose file name is wt_32.ico.
Step 3:
Save follwing content as wt.reg, then run as administrator.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt_32.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"

To be noted, if the exe obtained after building code by yourself is wtd.exe, you need to change the above wt.exe to wtd.exe in the above registry.
Step 4:
Test
image

image

I have followed your instruction but this error occurs everywhere I start _Windows terminal here_

Like @saisandeepvaddi metioned,
For the wt.exe path, instead of using %LOCALAPPDATA% , use actual full path like C:\\Users\\[your_user_acc]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe.

Also, do not add startingDirectory in settings.

It works well in my PC. You can try it.

Tried to add wt.exe to registry, as it described before, but I have following error:
image

Terminal is started from command line (Win+R | "wt") normally.

I think the customization of the new Terminal is a strong point. What if this were in the settings? Say, "ExplorerIntegration": true. Then a batch script could add them like in the FluentTerminal project.

Hey, I just spent a bit hacking around being able to open Windows Terminal in a specific right click folder, and thought it might be interesting/useful for someone. This also appears to work when you switch into the linux subsystem, but not CMD. You could also just not use the powershell profile and use the $env with a slightly nicer name to get a variable to use across the three.

Assuming you've followed the guide above, you need two extra files:

C:\Users\[Your Username]AppData\Local\terminal\launchwt.bat

set wt_powershell_dir=%cd%
start %LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe
exit

C:\Users\[Your Username]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

if (Test-Path $env:wt_powershell_dir) {
   cd $env:wt_powershell_dir
   Remove-Item Env:\wt_powershell_dir
}

You will also need to go to the registry key you've installed and updated it to point at the batch file:

Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command

C:\Users\[Your Username]\AppData\Local\terminal\launchwt.bat

It's been fun playing around with the terminal so far, thanks heaps 😄.

@minhtuanta Try to delete startingDirectory in settings. 😊

Deleting startingDirectory works for me. What a sneaky setting 😛

As an alternative to the right click menu (awesome work so far): if you highlight the address bar of your current directory by pressing ctrl+l or clicking it and then type wt.exe, windows terminal will open your default shell in that directory.

@kaeside want to add- open default shell in current directory "in a new tab, if Terminal is already running."

You can get the real icon from the repo in github

@kaeside Not sure what version you're using but I always open Command Prompt this way (Alt + D, enter cmd) and it opens in present working directory but in case of Windows Terminal, it always open in the User directory.
At least for Version: 0.3.2171.0

Yes, this is because of startingDirectory, which is mentioned in a number of other comments in this thread. The fix is #607, which is also mentioned.

Tried to add wt.exe to registry, as it described before, but I have following error:
image

Terminal is started from command line (Win+R | "wt") normally.

In my case, wt.exe is located in C:\Users\[your_user_name]\AppData\Local\Microsoft\WindowsApps\.
And you can check every item in your environment variable %PATH%.

I recently updates windows terminal to Version: 0.5.2661.0.
Suddenly right-click context menu "open Windows terminal here" always start on C:\Users\[username], even when the profiles.json doesn't contain "startingDirectory".

What fix this for me was, adding "startingDirectory" : "." to the profiles.json.
Hope this help someone with similar issue.

A batch file that solves the problems with @yanglr's solution. In particular, the reason why the environment variables weren't working is because the strings containing them need to be added as REG_MULTI_SZ, not the default REG_SZ.

@echo off

reg.exe add "HKEY_CLASSES_ROOT\Directory\Background\shell\wt" /f /ve /d "Windows Terminal here"
reg.exe add "HKEY_CLASSES_ROOT\Directory\Background\shell\wt" /f /v "Icon" /t REG_EXPAND_SZ /d "\"%%USERPROFILE%%\Downloads\terminal.ico\""

reg.exe add "HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command" /f /ve /t REG_EXPAND_SZ /d "\"%%LOCALAPPDATA%%\Microsoft\WindowsApps\wt.exe\""

pause

Dump the above into a .bat file, customise the icon location to taste, save and run as Administrator, enjoy. And don't forget @rendrap's comment about changing the profile startingDirectory to . to make this work as expected.

@IanKemp well now environment variables works thanks but since the last update from app store it doesn't open in the directory do you have any solution for that?

@poqdavid I suggest you read @rendrap's comment, as I suggested.

So I've got the right-click "Open Windows Terminal here" working, but I can't figure out how to get it to run as Administrator. I've tried using runas in the Registry as well as the runas verb, with no luck.

However, if I press Windows key -> type Terminal -> click "Run as administrator" I do get a Windows Terminal running as admin, so it's definitely possible.

What is the secret sauce to setup WT's environment so that it starts as administrator?

@IanKemp If you mainly work with powershell, you can try sudo. This script allow you run commands as admin in a non-elevated powershell window.

Here is my file i use it does not open the path but it at least look nice:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="%ProgramFiles%\\WindowsApps\\Microsoft.WindowsTerminal_0.5.2681.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"
"Extended"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\andre\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"


[HKEY_CLASSES_ROOT\Directory\shell\wt]
@="Windows terminal here"
"Icon"="%ProgramFiles%\\WindowsApps\\Microsoft.WindowsTerminal_0.5.2681.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"
"Extended"=""

[HKEY_CLASSES_ROOT\Directory\shell\wt\command]
@="C:\\Users\\andre\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

EDIT: As mentioned above set your start Directory to "." in your profiles.json

"startingDiretory" : ".",

I use Windows Terminal with Ubuntu WSL
Is there any way to make it so that if I use "Windows terminal here", it opens in that directory I'm in, but if I just start Windows Terminal normally, it drops me into Ubuntu ~?

Making it drop me into Ubuntu home by default was relatively easy to do like this:
"commandline" : "wsl.exe ~ -d Ubuntu-18.04"
but then adding "startingDirectory": "." naturally doesn't bring the expected result for the context menu shortcut. Without the ~ in the commandline it spawns a shell in /mnt/c/Windows/System32

Here is a snippet of my settingss file:

    "defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
    "profiles":
    [
        {
            "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
            "name": "Ubuntu",
            // ... SNIPP
            //"startingDirectory" : "\\\\wsl$\\Ubuntu\\home\\andre",
            "startingDirectory" : ".",
            // ... SNIPP
        },
        // ... SNIPP
    ]

This one opens the directory your in when using Windows terminal here. But will open /mnt/c/Windows/System32 when terminal is open normally. My self have not solved this issue ether.
As you can see i also hard defined the home directory earlier before starting to use "."

@zambelly Not currently. That scenario would probably require #878 to be fixed to be able to support.

So I've got the right-click "Open Windows Terminal here" working, but I can't figure out how to get it to run as Administrator. I've tried using runas in the Registry as well as the runas verb, with no luck.

However, if I press Windows key -> type Terminal -> click "Run as administrator" I do get a Windows Terminal running as admin, so it's definitely possible.

What is the secret sauce to setup WT's environment so that it starts as administrator?

@IanKemp You may try this way by changing the value of command under the registry key runas:
cmd.exe /s /c pushd "%V" & start wt.exe

Though it is a little bit circuitous, at least this works for me.

is there a way to, if there is already an instance of wt.exe running, to instead add a tab there?
And is there a way to specify which profile the new tab has?

Tried to add wt.exe to registry, as it described before, but I have following error:
image

Terminal is started from command line (Win+R | "wt") normally.

Same issue on my part, don't know how to fix it. Registry file as follows:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Open Windows terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"


[HKEY_CLASSES_ROOT\Directory\shell\wt]
@="Open Windows terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt.ico"

[HKEY_CLASSES_ROOT\Directory\shell\wt\command]
@="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"

You need to have a absolute path and not use a variable
see: https://github.com/microsoft/terminal/issues/1060#issuecomment-536322970

I feel like this is the reason I'm not using Terminal more, as the way I open the command prompt is 80% from File Explorer. The rest is from Win+R+cmd+Enter, and I just learned about the wt alias, so that'll help.

When this is done, there'd be a great opportunity to expose it in in Settings as well where they have the PowerShell/CMD switch:

image

It'd be great to just have the option to select the preferred shell as a drop-down and have Terminal as an option if it's installed.

@michael-hawker what you're really looking for here is #492 😁

I automated the whole process into one bat file that you need to run as an admin.
Add Windows Terminal to context menu.zip
You still need to modify starting directory in profiles.json to "startingDirectory" : ".",

@Restia666Ashdoll that doesn't seem to get the .ico correctly

Works here though
image

Try this. Open the location of terminal.ico file. Now, go to adress bar and type "cmd".
Now, in Command Prompt enter the following command
xcopy "terminal.ico" "%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\" /b /v /y /q

Doesn't work

Just open "%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState" and manually copy the ico file then

Yeah I have done that but the problem is the registry key is not picking up the ico

I automated the whole process into one bat file that you need to run as an admin.
Add Windows Terminal to context menu.zip
You still need to modify starting directory in profiles.json to "startingDiretory" : ".",

Warning: There's a miss typing, should use "startingDirectory" : "." instead.

what about the key HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\wt ? It doesn't need admin permission

what about the key HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\wt ? It doesn't need admin permission

It's only for current user.

@Restia666Ashdoll and @musm, logout and login again after copying the ico file to the LocalAppData folder. The icon will appear then.

image

@edrohler Why are you quoting me? I don't have this issue.

@Horacehxw that's only if it's the last entry.

@Restia666Ashdoll I quoted you thinking you might want to share the information with your batch script if anyone else asks. :)

logout and login again

@edrohler Use task manager to restart explorer.exe is enough.
When you have at least 1 folder open, task manager will show Restart for it in the normal position of End Task(in the first page, not process details)

@Horacehxw that's only if it's the last entry.

The problem is not comma at the end, but the spelling of "Directory". The previous one is missing "c".

I automated the whole process into one bat file that you need to run as an admin.
Add Windows Terminal to context menu.zip
You still need to modify starting directory in profiles.json to "startingDirectory" : ".",

I tried this, But two problem: There is now startingDirectory in profile.json :


// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

    "profiles":
    [
        {
            // Make changes here to the powershell.exe profile
            "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "name": "Windows PowerShell",
            "commandline": "powershell.exe",
            "hidden": false
        },
        {
            // Make changes here to the cmd.exe profile
            "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "name": "cmd",
            "commandline": "cmd.exe",
            "hidden": false
        },
        {
            "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
            "hidden": false,
            "name": "Azure Cloud Shell",
            "source": "Windows.Terminal.Azure"
        },
        {
            "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
            "hidden": false,
            "name": "Ubuntu-18.04",
            "source": "Windows.Terminal.Wsl"
        }
    ],

    // Add custom color schemes to this array
    "schemes": [],

    // Add any keybinding overrides to this array.
    // To unbind a default keybinding, set the command to "unbound"
    "keybindings": []
}

Another problem is that terminal not actually go to the correct 'here' path it start only on my user path

I automated the whole process into one bat file that you need to run as an admin.
Add Windows Terminal to context menu.zip
You still need to modify starting directory in profiles.json to "startingDiretory" : ".",

Warning: There's a miss typing, should use "startingDirectory" : "." instead.

This works great if you right and open here ...
The one issue I have noticed is that if you open the terminal normally... the default directory is system32... is there any way to override and have it use user folder when opened normally by any chance?

I automated the whole process into one bat file that you need to run as an admin.
Add Windows Terminal to context menu.zip
You still need to modify starting directory in profiles.json to "startingDirectory" : ".",

I tried this, But two problem: There is now startingDirectory in profile.json :


// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

    "profiles":
    [
        {
            // Make changes here to the powershell.exe profile
            "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "name": "Windows PowerShell",
            "commandline": "powershell.exe",
            "hidden": false
        },
        {
            // Make changes here to the cmd.exe profile
            "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "name": "cmd",
            "commandline": "cmd.exe",
            "hidden": false
        },
        {
            "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
            "hidden": false,
            "name": "Azure Cloud Shell",
            "source": "Windows.Terminal.Azure"
        },
        {
            "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
            "hidden": false,
            "name": "Ubuntu-18.04",
            "source": "Windows.Terminal.Wsl"
        }
    ],

    // Add custom color schemes to this array
    "schemes": [],

    // Add any keybinding overrides to this array.
    // To unbind a default keybinding, set the command to "unbound"
    "keybindings": []
}

Another problem is that terminal not actually go to the correct 'here' path it start only on my user path

Here is my profile if you are interested

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "globals" : 
    {
        "alwaysShowTabs" : true,
        "defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "disabledProfileSources": [
        "Windows.Terminal.Azure"
    ],
        "initialCols" : 120,
        "initialRows" : 30,
        "keybindings" : 
        [
            {
                "command" : "closePane",
                "keys" : 
                [
                    "ctrl+shift+w"
                ]
            },
            {
                "command" : "copy",
                "keys" : 
                [
                    "ctrl+shift+c"
                ]
            },
            {
                "command" : "duplicateTab",
                "keys" : 
                [
                    "ctrl+shift+d"
                ]
            },
            {
                "command" : "newTab",
                "keys" : 
                [
                    "ctrl+shift+t"
                ]
            },
            {
                "command" : "newTabProfile0",
                "keys" : 
                [
                    "ctrl+shift+1"
                ]
            },
            {
                "command" : "newTabProfile1",
                "keys" : 
                [
                    "ctrl+shift+2"
                ]
            },
            {
                "command" : "newTabProfile2",
                "keys" : 
                [
                    "ctrl+shift+3"
                ]
            },
            {
                "command" : "newTabProfile3",
                "keys" : 
                [
                    "ctrl+shift+4"
                ]
            },
            {
                "command" : "newTabProfile4",
                "keys" : 
                [
                    "ctrl+shift+5"
                ]
            },
            {
                "command" : "newTabProfile5",
                "keys" : 
                [
                    "ctrl+shift+6"
                ]
            },
            {
                "command" : "newTabProfile6",
                "keys" : 
                [
                    "ctrl+shift+7"
                ]
            },
            {
                "command" : "newTabProfile7",
                "keys" : 
                [
                    "ctrl+shift+8"
                ]
            },
            {
                "command" : "newTabProfile8",
                "keys" : 
                [
                    "ctrl+shift+9"
                ]
            },
            {
                "command" : "nextTab",
                "keys" : 
                [
                    "ctrl+tab"
                ]
            },
            {
                "command" : "openSettings",
                "keys" : 
                [
                    "ctrl+,"
                ]
            },
            {
                "command" : "paste",
                "keys" : 
                [
                    "ctrl+shift+v"
                ]
            },
            {
                "command" : "prevTab",
                "keys" : 
                [
                    "ctrl+shift+tab"
                ]
            },
            {
                "command" : "scrollDown",
                "keys" : 
                [
                    "ctrl+shift+down"
                ]
            },
            {
                "command" : "scrollDownPage",
                "keys" : 
                [
                    "ctrl+shift+pgdn"
                ]
            },
            {
                "command" : "scrollUp",
                "keys" : 
                [
                    "ctrl+shift+up"
                ]
            },
            {
                "command" : "scrollUpPage",
                "keys" : 
                [
                    "ctrl+shift+pgup"
                ]
            },
            {
                "command" : "switchToTab0",
                "keys" : 
                [
                    "ctrl+alt+1"
                ]
            },
            {
                "command" : "switchToTab1",
                "keys" : 
                [
                    "ctrl+alt+2"
                ]
            },
            {
                "command" : "switchToTab2",
                "keys" : 
                [
                    "ctrl+alt+3"
                ]
            },
            {
                "command" : "switchToTab3",
                "keys" : 
                [
                    "ctrl+alt+4"
                ]
            },
            {
                "command" : "switchToTab4",
                "keys" : 
                [
                    "ctrl+alt+5"
                ]
            },
            {
                "command" : "switchToTab5",
                "keys" : 
                [
                    "ctrl+alt+6"
                ]
            },
            {
                "command" : "switchToTab6",
                "keys" : 
                [
                    "ctrl+alt+7"
                ]
            },
            {
                "command" : "switchToTab7",
                "keys" : 
                [
                    "ctrl+alt+8"
                ]
            },
            {
                "command" : "switchToTab8",
                "keys" : 
                [
                    "ctrl+alt+9"
                ]
            }
        ],
        "requestedTheme" : "system",
        "showTabsInTitlebar" : true,
        "showTerminalTitleInTitlebar" : true,
        "wordDelimiters" : " ./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}~?\u2502"
    },
    "profiles" : 
    [
        {
            "acrylicOpacity" : 0.75,
            "background" : "#012456",
            "closeOnExit" : true,
            "colorScheme" : "One Half Dark",
            "commandline" : "powershell.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
            "name" : "Windows PowerShell",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "One Half Dark",
            "commandline" : "cmd.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
            "name" : "Command Prompt",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "flat-ui-v1",
            "commandline" : "cmd.exe /c set MSYS=winsymlinks:nativestrict&& set MSYS2_PATH_TYPE=inherit&& msys2 -i -l",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "historySize" : 9001,
            "icon" : "%SCOOP%\\apps\\msys2\\current\\msys2.ico",
            "name" : "MSYS2",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "flat-ui-v1",
            "commandline" : "cmd.exe /c set MSYS=winsymlinks:nativestrict&& set MSYS2_PATH_TYPE=inherit&& mingw64 -i -l",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "historySize" : 9001,
            "icon" : "%SCOOP%\\apps\\msys2\\current\\mingw64.ico",
            "name" : "MinGW64",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {         
            "guid": "{a5a97cb8-8961-5535-816d-772efe0c6a3f}",
            "acrylicOpacity" : 0.75,
            "background" : "#012456",
            "closeOnExit" : true,
            "colorScheme" : "flat-ui-v1",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "hidden": false,
            "name": "Arch",
            "icon" : "%SCOOP%\\apps\\archwsl\\current\\arch.ico",
            "source": "Windows.Terminal.Wsl",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {        
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "flat-ui-v1",
            "commandline" : "\"%SCOOP%\\apps\\git-with-openssh\\current\\bin\\bash.exe\" -i -l",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "historySize" : 9001,
            "icon" : "%SCOOP%\\apps\\git-with-openssh\\current\\mingw64\\share\\git\\git-for-windows.ico",
            "name" : "Git Bash",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        }
    ],
        {
            "acrylicOpacity" : 0.75,
            "background" : "#012456",
            "closeOnExit" : true,
            "colorScheme" : "One Half Dark",
            "commandline" : "powershell.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
            "backgroundImage" : "ms-appdata:///local/1537295612521.png",
            "backgroundImageOpacity" : 0.75,
            "backgroundImageStrechMode" : "fill",
            "name" : "Windows PowerShell",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "One Half Dark",
            "commandline" : "cmd.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
            "backgroundImage" : "ms-appdata:///local/1503827082075.png",
            "backgroundImageOpacity" : 0.75,
            "backgroundImageStrechMode" : "fill",
            "name" : "Command Prompt",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "flat-ui-v1",
            "commandline" : "cmd.exe /c set MSYS=winsymlinks:nativestrict&& set MSYS2_PATH_TYPE=inherit&& msys2 -i -l",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "historySize" : 9001,
            "icon" : "%SCOOP%\\apps\\msys2\\current\\msys2.ico",
            "backgroundImage" : "ms-appdata:///local/1504637576364.png",
            "backgroundImageOpacity" : 0.75,
            "backgroundImageStrechMode" : "fill",
            "name" : "MSYS2",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "flat-ui-v1",
            "commandline" : "cmd.exe /c set MSYS=winsymlinks:nativestrict&& set MSYS2_PATH_TYPE=inherit&& mingw64 -i -l",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "historySize" : 9001,
            "icon" : "%SCOOP%\\apps\\msys2\\current\\mingw64.ico",
            "backgroundImage" : "ms-appdata:///local/704387.png",
            "backgroundImageOpacity" : 0.75,
            "backgroundImageStrechMode" : "fill",
            "name" : "MinGW64",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {         
            "guid": "{a5a97cb8-8961-5535-816d-772efe0c6a3f}",
            "acrylicOpacity" : 0.75,
            "background" : "#012456",
            "closeOnExit" : true,
            "colorScheme" : "flat-ui-v1",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "hidden": false,
            "name": "Arch",
            "icon" : "%SCOOP%\\apps\\archwsl\\current\\arch.ico",
            "backgroundImage" : "ms-appdata:///local/1507634976184.jpg",
            "backgroundImageOpacity" : 0.75,
            "backgroundImageStrechMode" : "fill",
            "source": "Windows.Terminal.Wsl",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        },
        {        
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "flat-ui-v1",
            "commandline" : "\"%SCOOP%\\apps\\git-with-openssh\\current\\bin\\bash.exe\" -i -l",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "historySize" : 9001,
            "icon" : "%SCOOP%\\apps\\git-with-openssh\\current\\mingw64\\share\\git\\git-for-windows.ico",
            "backgroundImage" : "ms-appdata:///local/1496315646560.png",
            "backgroundImageOpacity" : 0.75,
            "backgroundImageStrechMode" : "fill",
            "name" : "Git Bash",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        }
    ],
    "schemes" : 
    [
        {
            "background":"#000000",
            "black":"#000000",
            "blue":"#2980b9",
            "brightBlack":"#7f8c8d",
            "brightBlue":"#3498db",
            "brightCyan":"#1abc9c",
            "brightGreen":"#2ecc71",
            "brightPurple":"#9b59b6",
            "brightRed":"#e74c3c",
            "brightWhite":"#ecf0f1",
            "brightYellow":"#f1c40f",
            "cyan":"#16a085",
            "foreground":"#ecf0f1",
            "green":"#27ae60",
            "name":"flat-ui-v1",
            "purple":"#8e44ad",
            "red":"#c0392b",
            "white":"#ecf0f1",
            "yellow":"#f39c12"
        },
        {
            "background" : "#0C0C0C",
            "black" : "#0C0C0C",
            "blue" : "#0037DA",
            "brightBlack" : "#767676",
            "brightBlue" : "#3B78FF",
            "brightCyan" : "#61D6D6",
            "brightGreen" : "#16C60C",
            "brightPurple" : "#B4009E",
            "brightRed" : "#E74856",
            "brightWhite" : "#F2F2F2",
            "brightYellow" : "#F9F1A5",
            "cyan" : "#3A96DD",
            "foreground" : "#CCCCCC",
            "green" : "#13A10E",
            "name" : "Campbell",
            "purple" : "#881798",
            "red" : "#C50F1F",
            "white" : "#CCCCCC",
            "yellow" : "#C19C00"
        },
        {
            "background" : "#000000",
            "black" : "#000000",
            "blue" : "#000080",
            "brightBlack" : "#808080",
            "brightBlue" : "#0000FF",
            "brightCyan" : "#00FFFF",
            "brightGreen" : "#00FF00",
            "brightPurple" : "#FF00FF",
            "brightRed" : "#FF0000",
            "brightWhite" : "#FFFFFF",
            "brightYellow" : "#FFFF00",
            "cyan" : "#008080",
            "foreground" : "#C0C0C0",
            "green" : "#008000",
            "name" : "Vintage",
            "purple" : "#800080",
            "red" : "#800000",
            "white" : "#C0C0C0",
            "yellow" : "#808000"
        },
        {
            "background" : "#282C34",
            "black" : "#282C34",
            "blue" : "#61AFEF",
            "Grey" : "#FFFFFF",
            "darkGrey" : "#FFFFFF",
            "brightBlack" : "#5A6374",
            "brightBlue" : "#61AFEF",
            "brightCyan" : "#56B6C2",
            "brightGreen" : "#98C379",
            "brightPurple" : "#C678DD",
            "brightRed" : "#E06C75",
            "brightWhite" : "#DCDFE4",
            "brightYellow" : "#E5C07B",
            "cyan" : "#56B6C2",
            "foreground" : "#DCDFE4",
            "green" : "#98C379",
            "name" : "One Half Dark",
            "purple" : "#C678DD",
            "red" : "#E06C75",
            "white" : "#DCDFE4",
            "yellow" : "#E5C07B"
        },
        {
            "background" : "#FAFAFA",
            "black" : "#383A42",
            "blue" : "#0184BC",
            "brightBlack" : "#4F525D",
            "brightBlue" : "#61AFEF",
            "brightCyan" : "#56B5C1",
            "brightGreen" : "#98C379",
            "brightPurple" : "#C577DD",
            "brightRed" : "#DF6C75",
            "brightWhite" : "#FFFFFF",
            "brightYellow" : "#E4C07A",
            "cyan" : "#0997B3",
            "foreground" : "#383A42",
            "green" : "#50A14F",
            "name" : "One Half Light",
            "purple" : "#A626A4",
            "red" : "#E45649",
            "white" : "#FAFAFA",
            "yellow" : "#C18301"
        },
        {
            "background" : "#002B36",
            "black" : "#073642",
            "blue" : "#268BD2",
            "brightBlack" : "#002B36",
            "brightBlue" : "#839496",
            "brightCyan" : "#93A1A1",
            "brightGreen" : "#586E75",
            "brightPurple" : "#6C71C4",
            "brightRed" : "#CB4B16",
            "brightWhite" : "#FDF6E3",
            "brightYellow" : "#657B83",
            "cyan" : "#2AA198",
            "foreground" : "#839496",
            "green" : "#859900",
            "name" : "Solarized Dark",
            "purple" : "#D33682",
            "red" : "#DC322F",
            "white" : "#EEE8D5",
            "yellow" : "#B58900"
        },
        {
            "background" : "#FDF6E3",
            "black" : "#073642",
            "blue" : "#268BD2",
            "brightBlack" : "#002B36",
            "brightBlue" : "#839496",
            "brightCyan" : "#93A1A1",
            "brightGreen" : "#586E75",
            "brightPurple" : "#6C71C4",
            "brightRed" : "#CB4B16",
            "brightWhite" : "#FDF6E3",
            "brightYellow" : "#657B83",
            "cyan" : "#2AA198",
            "foreground" : "#657B83",
            "green" : "#859900",
            "name" : "Solarized Light",
            "purple" : "#D33682",
            "red" : "#DC322F",
            "white" : "#EEE8D5",
            "yellow" : "#B58900"
        }
    ]
}

@Restia666Ashdoll Thanks! it worked but everytime it shows a pop up:

Capture

@foremtehan Since, you dont use msys2,mingw64,arch and git bash, you dont need them. Now, try this in profiles for Ubuntu.

        {         
            "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
            "acrylicOpacity" : 0.75,
            "background" : "#012456",
            "closeOnExit" : true,
            "colorScheme" : "flat-ui-v1",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "hidden": false,
            "name": "Ubuntu",
            "source": "Windows.Terminal.Wsl",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : ".",
            "useAcrylic" : true
        }

Make sure theres no comma in the final profile section

I automated the whole process into one bat file that you need to run as an admin.
Add Windows Terminal to context menu.zip
You still need to modify starting directory in profiles.json to "startingDiretory" : ".",

Warning: There's a miss typing, should use "startingDirectory" : "." instead.

This works great if you right and open here ...
The one issue I have noticed is that if you open the terminal normally... the default directory is system32... is there any way to override and have it use user folder when opened normally by any chance?

Hey! I had this issue too. A quick and dirty fix is to add a cd command to your .bashrc file within the WSL terminal.
echo 'cd ~' >> ~/.bashrc

That defeats the whole purpose of this thread, since it will always in '~' directory regardless of where you open the terminal. Just type 'cd ~' after opening the terminal in wsl/msys2/mingw64/git bash.

I automated the whole process into one bat file that you need to run as an admin.
Add Windows Terminal to context menu.zip
You still need to modify starting directory in profiles.json to "startingDiretory" : ".",

Warning: There's a miss typing, should use "startingDirectory" : "." instead.

This works great if you right and open here ...
The one issue I have noticed is that if you open the terminal normally... the default directory is system32... is there any way to override and have it use user folder when opened normally by any chance?

Hey! I had this issue too. A quick and dirty fix is to add a cd command to your .bashrc file within the WSL terminal.
echo 'cd ~' >> ~/.bashrc

That defeats the whole purpose of this thread, since it will always in '~' directory regardless of where you open the terminal. Just type 'cd ~' after opening the terminal in wsl/msys2/mingw64/git bash.

This will also set the startup directory to "~" when you click "Open Windows Terminal Here". You could simply add a if condition.
if [ "$PWD" = "/mnt/c/Windows/System32" ]; then cd ~ fi

@Restia666Ashdoll and @musm, logout and login again after copying the ico file to the LocalAppData folder. The icon will appear then.

image

How did you add the "Open with Code" option?

@Restia666Ashdoll and @musm, logout and login again after copying the ico file to the LocalAppData folder. The icon will appear then.
image

How did you add the "Open with Code" option?

when you install code it asks you if you want to add a shell open with code option

For those who installed the terminal from windows store, the command is:

explorer.exe shell:appsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App

Windows Terminal also adds wt.exe to the path, which makes the above error prone snippet redundant.

I applaud everyone's work here, but I just wanna provide a simpler solution which is good enough for me and maybe for a lot of you too:

IMPORTANT PREPARATION: In your Windows Terminal settings file, ensure that your default shell's profile contains "startingDirectory": ".", which means "start in the current working dir". (If you skip this step, Windows Terminal will ignore the working dir and will always start in your home directory.)

Now for the instructions:

  1. Navigate to some fun folder in Explorer!
  2. Press Ctrl-L, type wt, and press Enter. That's it! Done! Windows Terminal opens in the folder you're looking at.

The text in bold above is the actual instruction. Hehe. That's it!

I have no need for a right-click menu item. It's pretty rare that I need to open the terminal in the current dir, and I am fine with just Ctrl-L, wt, Enter. It's super quick and ez.

@VideoPlayerCode That's a great solution! Thanks a lot!

@VideoPlayerCode Thanks for the great tip ! it doesn't solve the "run as administrator" case, though.

If anyone gets the following error, after using the solution of @yanglr
explorer_error

You can use the entire path, instead of %LOCALAPPDATA%:

So instead of
[HKEY_CLASSES_ROOT\Directory\Background\shellwtcommand]
@="%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe"

Use (with your username in the place of 'thull'):
[HKEY_CLASSES_ROOT\Directory\Background\shellwtcommand]
@=""C:\Users\thullAppData\Local\Microsoft\WindowsAppswt.exe""

@ad1tyawagh Happy that I helped you! :-)

@lllopo I would love to help but it seems that "Run as administrator" is not possible on Windows Store apps (I installed Windows Terminal via Chocolatey direct from the installer, but it's still a Windows Store app).

Here's my current setup:

  • PowerShell is my default shell.
  • My PowerShell config contains these extra lines:
function EditProfile { notepad "$profile" }
function GoAdmin { start-process pwsh –verb runAs }

When you type GoAdmin, an admin rights dialog pops up and then PowerShell starts as admin in a separate shell window (not hosted by Windows Terminal), in the exact folder you were navigated into. This is convenient and is enough for me, because I only use this for chocolatey install/update packages. Haven't really needed admin rights for anything else.

But for you, I wanted to try to improve it to be able to launch Windows Terminal itself in admin rights. However, it fails:

# Works but not admin rights:
function GoAdmin { start-process "$env:LOCALAPPDATA\Microsoft\WindowsApps\wt.exe" }

function GoAdmin { start-process explorer.exe shell:appsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App }

# Fails with "This command cannot be run due to the error: The file cannot be accessed by the system.":
function GoAdmin { start-process "$env:LOCALAPPDATA\Microsoft\WindowsApps\wt.exe" -verb runAs }

# Successfully launches explorer.exe as admin, which in turn launches Windows Terminal as non-admin, meh:
function GoAdmin { start-process explorer.exe shell:appsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App -verb runAs }

So unless there is a way to fix the "The file cannot be accessed by the system" error, there's no way to launch Windows Terminal as admin via PowerShell scripts. Perhaps someone figures out a way. (Edit: Seems like the explanation for failing to launch wt as admin is that Windows Terminal is installed as the non-admin user and therefore cannot be found by the admin user. At least that's how I understand this message.)

If not, I hope you at least like the GoAdmin command I provided here, which does successfully launch a separate PowerShell window as admin. It's enough for me for administering chocolatey packages, so I don't mind much that it isn't a Windows Terminal window... (It's also pretty useful that it doesn't use Windows Terminal, because that means the "admin rights" shell is visually different, which is a good reminder to not use it for regular work, since admin rights are dangerous and propagate into all programs you launch via your shell, so shouldn't be used carelessly.)

PS: Replace pwsh with powershell if you're using the outdated, built-in "Windows PowerShell". I use PowerShell Core 6 instead, from https://github.com/PowerShell/PowerShell (installed via choco install powershell-core).

Another tip: I have pinned Windows Terminal itself to the leftmost position on my taskbar. That way, I can press Win+1 to instantly launch it (or give it focus if it's already launched). Very convenient. It also means that if I really want Windows Terminal itself to run as admin, I can just right click that taskbar icon, then right-click "Windows Terminal" in the menu that shows up, and finally "Run as administrator").

Final tip: After setting your startingDirectory to ".", the Windows Terminal will always open in the system32 folder if you launch it from a shortcut (such as from pinned taskbar or via start menu; but _not_ via Win+R or via explorer (the latter methods work properly)). But there's a quick way to get to your home folder: Just type cd and press enter to always go directly home.

Another way is to install the sudo command from Scoop
scoop install sudo
http://blog.lukesampson.com/sudo-for-windows
Apart from letting you run commands in elevated privileges you can also start an elevated PowerShell/Command Prompt session with sudo powershell or sudo cmd command.

@Restia666Ashdoll As mentioned in my answer, there is no need for third party "sudo" commands. PowerShell has a built-in "sudo": https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-6#examples

Example 5: Start PowerShell as an administrator

This example starts PowerShell by using the "Run as administrator" option.

Start-Process -FilePath "powershell" -Verb RunAs

I wrapped that as GoAdmin in my example. But someone could also wrap it as a function that they name "sudo" and make it take any command.

For example, as inspiration, I wanted the command touch to create 0-byte empty files easily, and I wanted it to take multiple arguments for multiple files at once. So I wrote this PowerShell function and put it in my config so that it's always available:

function touch() { for ($i=0; $i -le $args.length; $i++) { $name = $args[$i]; if ($name -ne $null -and $name.GetType().Name -eq "String") { $name = $name.Trim(); if ($name.length -gt 0) { New-Item -ItemType file "$name" } } } }

Something very similar could be done if you wanted to make a generic sudo command.

Or just use GoAdmin as shown above...

@VideoPlayerCode That command can only be used for few powershell commands. You cant do something like sudo pip install httpie or sudo Install-Module oh-my-posh -Force. Heck, you can even use Chocolatey from regular powershell like sudo choco install mpv(although I personally dont like Chocolatey). Ofcourse, sudo for windows also has limitations.

@Restia666Ashdoll Thanks, you pushed me to write the "sudo" command I explained above. :-)

function sudo() {
    [string[]]$cmd = @("-command")
    for ($i=0; $i -le $args.length; $i++) {
        $val = $args[$i]
        if ($val -ne $null) {
            $cmd += [string]$val;
        }
    }
    if ($cmd.length -ge 2) {
        $cmd += "; pause"
        #Write-Host $cmd
        Start-Process pwsh -ArgumentList $cmd –Verb RunAs
    }
}

_(If someone is using the regular, outdated powershell that is bundled with windows, then replace the pwsh with powershell above.)_

Running sudo choco install sysinternals in a non-admin session will now execute that command in an admin session.

Note that PowerShell's Start-Process does not support spawning admin subshells that output directly inside "host" non-admin shells, so it runs in a popup window, and pauses so that you can read the result before closing that window. Good enough for me.

I did have a look at https://github.com/lukesampson/psutils/blob/master/sudo.ps1 (the script you proposed), but felt like it's a bit icky to call kernel functions to attach the output of an admin subprocess into the running terminal, and worrying about "leaking" unsafe privileges into the host process or all exploits that become possible when the input/output of an admin process is owned by a non-admin process (yikes). There was also another called wsudo at https://github.com/noseratio/choco/tree/master/wsudo, but I didn't really look deeply into it. I just wrote my own version instead.

Thanks for the push, again. It is nice to have a command for quickly running a single action as admin. My GoAdmin command posted earlier is still super useful for starting a separate admin console which supports typing multiple actions as usual. But running single commands is now a bit easier with this new command!

PS: If someone wonders where to put this or all my other functions, just type Write-Host $Profile (write-host is "echo" in powershell) to see the profile path, and create that file if it's missing, and then put the functions in there and restart PowerShell.

(Those "kernel" functions are actually this team's officially-supported console APIs, they just happen to live in a library called kernel32 (for legacy reasons.))

@DHowett-MSFT Ahh. The sudo.ps1 code by Luke Sampson says DllImport("kernel32.dll"), but you're saying it's totally fine to use those functions to redirect the output of the admin shell to the current shell?

To be frank it's supposed behave like sudo on unix systems. Almost, everyone who uses Scoop, uses that. It's what I want - run a command with elevated privileges inside the current shell. And it's what everyone wishes for, if Microsoft made a proper 'sudo for windows'.

Thanks for the great discussion on this topic! Would you mind diverting discussion about things that aren’t the context menu option elsewhere? For sudo, we have #1032

Yeah, some people asked for a way to "sudo" and things derailed a bit. ;-)

@DHowett-MSFT Sorry, for getting off-topic. It just came up because the prospect of starting terminal as admin. I will stop.

Hey, no problem! Happens to everyone. :smile:

Here's my solution
It acts pretty the same as PowerShell 7 does and also can run with Administrator rights
https://github.com/nt4f04uNd/wt-contextmenu
There you can find a guide how to implement it and all needed files

@nt4f04uNd Can you also add scoop install nicrmd to your guide ?
https://github.com/ScoopInstaller/Main/blob/master/bucket/nircmd.json

@Restia666Ashdoll done

I dont see the need for open cmd prompt here replacement.

In the address bar click it and type wt.exe and press enter. Windows Terminal in the with the current explore window as the CWD.

@em00k Different folks have their own workflows, and that's alright :smile:

This is work for me https://github.com/microsoft/terminal/issues/1060#issuecomment-497539461 and to resolve initial directory for my user folder, i create a shortcut aiming to my '%USERPROFILE%' and put him in my start menu and taskbar.

But will be very usefull if we can use a folder parameter to open directory in wt.exe app.

image

Here's what worked for me for 0.7.3451.0 (Some changes needed to @yanglr 's original comment)

1) Download the official Windows Terminal icon and put it somewhere
https://raw.githubusercontent.com/microsoft/terminal/master/res/terminal.ico

2) Edit the Windows Terminal config. Make the profile that you want to open the current directory with default.
Add
"startingDirectory": "."
to that profile, so that the current directory is the starting directory

3) Create and run a file wt.reg, with the following, substituting items in curly braces with real paths (remembering double slashes).

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal Here"
"Icon"="{full_path_to_icon}\\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\{windows_user_directory}\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

(Substitue HKEY_CLASSES_ROOT for HKEY_CURRENT_USER if you only want to change the current user)

4) Test. It should open the directory you are in when you right click.
I only tested this with cmd.exe as my default profile. I don't know if it works for other profile types.

Capture

Opens a Windows Terminal starting in the folder I right clicked in

Capture

At least change it to HKCU so you only change your own user account

@VideoPlayerCode thanks alot man solved my problem with windows terminal

@yangshuairocks Mine flashes not once, but twice when doing this, then prompts for admin.

I'd like “Open as a new tab in Windows Terminal.”
I don't want to get my desktop messed up with many Terminal windows.

P.S.
"startingDirectory": "." makes $PWD of the terminal opened from the start menu or the taskbar C:\Windows\System32.

Actually you don't need to write a full path. Terminal is present in the PATH variable. So just call wt command anywhere.
Or you can call UWP app itself shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App

Since the release of v0.9.433.0 you can now pass command-line parameters, so the following works with support for multiple profiles.

wt.reg:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\wt (Command)]
@="Open Terminal (Command)"
[HKEY_CLASSES_ROOT\Directory\shell\wt (Command)\command]
@="C:\\Users\\Sean\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe new-tab -d \"%1\" -p Command"

[HKEY_CLASSES_ROOT\Directory\shell\wt (PowerShell)]
@="Open Terminal (PowerShell)"
[HKEY_CLASSES_ROOT\Directory\shell\wt (PowerShell)\command]
@="C:\\Users\\Sean\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe new-tab -d \"%1\" -p PowerShell"

[HKEY_CLASSES_ROOT\Directory\shell\wt (Git Bash)]
@="Open Terminal (Git Bash)"
[HKEY_CLASSES_ROOT\Directory\shell\wt (Git Bash)\command]
@="C:\\Users\\Sean\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe new-tab -d \"%1\" -p \"Git Bash\""

[HKEY_CLASSES_ROOT\Directory\shell\wt (Ubuntu Bash)]
@="Open Terminal (Ubuntu Bash)"
[HKEY_CLASSES_ROOT\Directory\shell\wt (Ubuntu Bash)\command]
@="C:\\Users\\Sean\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe new-tab -d \"%1\" -p \"Ubuntu Bash\""

[HKEY_CLASSES_ROOT\Directory\shell\wt (Ubuntu Zsh)]
@="Open Terminal (Ubuntu Zsh)"
[HKEY_CLASSES_ROOT\Directory\shell\wt (Ubuntu Zsh)\command]
@="C:\\Users\\Sean\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe new-tab -d \"%1\" -p \"Ubuntu Zsh\""

profiles.json:

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{e5beb15e-da5c-4df7-815c-b0b0a865ef3f}",
    "initialRows": 50,
    "tabWidthMode": "titleLength",

    "profiles": {
        "defaults": {
            "cursorShape": "filledBox",
            "experimental.retroTerminalEffect": false,
            "fontFace": "Fira Code",
            "fontSize": 10,
            "padding": "2, 2, 2, 2",
            "suppressApplicationTitle": true
        },
        "list": [
            {
                "backgroundImage": "ms-appdata:///local/ubuntu.png",
                "backgroundImageAlignment": "bottomRight",
                "backgroundImageOpacity": 0.25,
                "backgroundImageStretchMode": "none",
                "commandline": "wsl.exe -d Ubuntu-18.04 --exec zsh --login",
                "colorScheme": "Solarized Dark",
                "guid": "{e5beb15e-da5c-4df7-815c-b0b0a865ef3f}",
                "icon": "ms-appdata:///local/ubuntu.png",
                "name": "Ubuntu Zsh",
                "startingDirectory": "//wsl$/Ubuntu-18.04/home/sean",
                "tabTitle": "Zsh"
            },
            {
                "backgroundImage": "ms-appdata:///local/ubuntu.png",
                "backgroundImageAlignment": "bottomRight",
                "backgroundImageOpacity": 0.25,
                "backgroundImageStretchMode": "none",
                "commandline": "wsl.exe -d Ubuntu-18.04 --exec bash --login",
                "colorScheme": "Solarized Dark",
                "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
                "icon": "ms-appdata:///local/ubuntu.png",
                "name": "Ubuntu Bash",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "//wsl$/Ubuntu-18.04/home/sean",
                "tabTitle": "Bash"
            },
            {
                "backgroundImage": "ms-appdata:///local/git-for-windows.png",
                "backgroundImageAlignment": "bottomRight",
                "backgroundImageOpacity": 0.25,
                "backgroundImageStretchMode": "none",
                "commandline": "C:\\Program Files\\Git\\bin\\bash.exe --login",
                "colorScheme": "Solarized Dark",
                "guid": "{78ccd05e-83d4-46c6-9a80-8865ff8ff720}",
                "icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
                "name": "Git Bash",
                "startingDirectory": "%USERPROFILE%",
                "tabTitle": "Bash"
            },
            {
                "backgroundImage": "ms-appdata:///local/powershell.png",
                "backgroundImageAlignment": "bottomRight",
                "backgroundImageOpacity": 0.25,
                "backgroundImageStretchMode": "none",
                "commandline": "powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "PowerShell",
                "tabTitle": "PS"
            },
            {
                "commandline": "cmd.exe",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "Command",
                "tabTitle": "Cmd"
            },
            {
                "acrylicOpacity": 0.9,
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "name": "Azure Shell",
                "source": "Windows.Terminal.Azure",
                "tabTitle": "Bash",
                "useAcrylic": true
            },
            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell Core",
                "source": "Windows.Terminal.PowershellCore"
            }
        ]
    },

    "schemes": [],

    "keybindings": []
}

@DHowett there's just one problem left... it doesn't re-use an existing wt instance and open a new tab.

@gitfool and that one's tracked by #4472 :smile:

You might make it _slightly_ more robust by using %1\. instead of just %1 -- right now, if you open it on the root of a drive, it'll not do what you're expecting. That's #4571

Not sure why, but @gitfool reg didn't do it for me. If I pass %V it does work, for example

C:\Users\islevin\AppData\Local\Microsoft\WindowsApps\wt -p "cmd" -d "%V"

Great job guys, this is almost perfect for me :)

The context menu entries are great, they open the expected folder, great. However, I launch Windows Terminal directly (from the start menu, for instance), the starting directory is my Windows home folder.

Is there anyway to make this default to my WSL home folder instead, without breaking the context menu entry?

@rfgamaral see my profile.json above. Given a startingDirectory default in the profile, the explorer context menu will override it, otherwise it will default as specified. You just need to replace my Linux distro and user name with yours.

@gitfool This is what I have but it's not working for me:

{
  "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
  "name": "Debian (WSL)",
  "commandline": "wsl.exe -d Debian --exec zsh --login",
  "startingDirectory": "//wsl$/Debian/home/ricardo",
  "acrylicOpacity": 1.0,
  "colorScheme": "Flat UI (tweaked)",
  "fontSize": 10,
  "hidden": false,
  "padding": "3, 2",
  "useAcrylic": true
}

@rfgamaral I can't see anything wrong with your config. Does your WSL home directory exist, or are you using a different profile when you launch Terminal directly?

Yes it does:

image

Nope, I only have this WSL profile.

@rfgamaral the Linux file system is case sensitive, so your profile startingDirectory should be //wsl$/Debian/home/Ricardo.

@rfgamaral the Linux file system is case sensitive, so your profile startingDirectory should be //wsl$/Debian/home/Ricardo.

Awesome, this fixed it! Thank you so much :)

Maybe this is out of scope of this issue, or maybe not, I'll just ask it anyway... Assuming the setup above described by @gitfool, I have this Windows folder C:\Users\Ricardo\Workspace and then I have a symlink inside WSL like ~/ Workspace -> /c/Users/AmaralR/Workspace/.

How cool it would be if right-clicking the Workspace folder inside explorer opened ~/Workspace instead of /c/Users/AmaralR/Workspace/? Do you guys think this is even remotely possible to achieve?

There is one problem for me. Rick click command only appears when I right click on folders. However, when I right click on an empty space within a folder the terminal entry does not appear (see gif), although VS Code and my default WSL distro (Pengwin) appear. I set Terminal, VS Code and Pengwin to Extended Shell mode (holding Shift).

GIF

My current config:
```Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shellwt]
@="Open Terminal here
"Extended"=""
"Icon"="D:\OneDrive\_Apps\.config\.icons\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\shellwtcommand]
@="C:\Users\steve\AppData\Local\Microsoft\WindowsApps\wt.exe new-tab -d "%1" -p "Pengwin""```

@Kalaschnik You'll also need one entry in HKCR\Directory\Background\Shell\WindowsTerminalHere

See https://github.com/shanselman/WindowsTerminalHere/pull/3/files

When I try that to launch a cmd tab in terminal I get

[error 0x8007010b when launching `cmd.exe']

There is one problem for me. Rick click command only appears when I right click on folders.

I am not sure what's the trouble that causes that, but you can check out this repository to make it more powershell-like

Gif demo

Hi all,
I implement a simple script to add context menu.
It work for me with windows terminal version 0.9.433.0

Thank you @nt4f04uNd and other all inspiring me

Repo: Windows-terminal-context-menu

Hi all,
I implement a simple script to add context menu.
It work for me with windows terminal version 0.9.433.0

Thank you @nt4f04uNd and other all inspiring me

Repo: Windows-terminal-context-menu

This is really great!!! however few notes:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7
you need to Set-ExecutionPolicy to Unrestricted to run it.

Also, this seems broken:

Copy-Item : The filename, directory name, or volume label syntax is incorrect.
At D:\Jeff\Documents\Windows-terminal-context-menu\SetupContextMenu.ps1:25 char:1
+ Copy-Item -Path "$PSScriptRoot\icons\*.ico" -Destination $resourcePat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand

this dir needs to be created either prior to or as part of the execution:
$env:LOCALAPPDATA\WindowsTerminalContextIcons\

Also, it says:

PS D:\Jeff\Documents\Windows-terminal-context-menu> .\SetupContextMenu.ps1
Add top layer menu (shell) => Registry::HKEY_CLASSES_ROOT\Directory\shell\WindowsTerminal
Add top layer menu (background) => Registry::HKEY_CLASSES_ROOT\Directory\shell\WindowsTerminal
Add new entry Git Bash
Add new entry Command Prompt
Add new entry PowerShell
Add new entry Azure Cloud Shell

but doesn't actually create it properly (Its missing icons and my Git Bash one is missing becuase i dont have the hidden key in it):
image

Added this under global definitions:
$gitbashIcoFileName = "git-bash.ico"

and this after line 101:

        elseif ($commandLine -like "*Git*bash.exe*") {
            $icoPath = $gitbashIcoFileName
        }

Looks like it just doesn't like loading the icons from:
%LOCALAPPDATA%\WindowsTerminalContextIcons\
... cause it looks fine in the registry key.

Instead I changed this line to:
$resourcePath = "$PSScriptRoot\icons\"

and removed:
Copy-Item -Path "$PSScriptRoot\icons\*.ico" -Destination $resourcePath

The problem is that if the folder doesn't exist the icons fail to be copied, just adding mkdir $resourcePath before the Copy-Item will solve that bit. I created an issue on your repo for that. Also, there seems to be problem with the Profile parsing on some scenarios. Anyways, thanks for the script!

Hi @Nomelas

Thank you for your response.
I have fixed the issue about icon missing. Just reinstall it again, and re-login.
I don't prefer to set $resourcePath to script location. Because user may remove the installer folder by any reason and then the icon will miss again.

The second thing, could you share your git bash profile? Because I am not set Git-bash on my WT.
I need a pattern to set the rule.

Hi @Nomelas

Thank you for your response.
I have fixed the issue about icon missing. Just reinstall it again, and re-login.
I don't prefer to set $resourcePath to script location. Because user may remove the installer folder by any reason and then the icon will miss again.

The second thing, could you share your git bash profile? Because I am not set Git-bash on my WT.
I need a pattern to set the rule.

I fixed all the issues and am submitting a PR

@Nomelas, unfortunately it does not work for me. I edited the config.json and run the ps script. After clicking the icon (no shell folders) I receive:
This file does not have a program associated with it for performing this action. Please install an app or, if one is already installed, create an association in the Default Apps Settings page.

Thats the registry chunk:
image

Guys, I know that I'm a little bit late to this party but how about to use OpenHere ? 😉

Run PowerShell with elevated permissions and type:

Install-Module OpenHere
Set-OpenHereShortcut -ShortcutType:WindowsTerminal

👍 who likes this!

@nt4f04uNd Maybe you should read the documentation first, specially Notes

i might have missed it, but settings starting directory to "." opens the installation directory of windows terminal when opened from start menu and open here context menu opens in the directory you are in. when using "%USERPROFILE%", opens both ways only in my user directory.

is there a way to make open here work and still have "%USERPROFILE%" as default path when opening from start menu? open here doesnt work with "%USERPROFILE%".

@eskoONE and others, yes, it is!
There is a solution with using -d argument. Check out https://github.com/nt4f04und/wt-contextmenu

Guys, I know that I'm a little bit late to this party but how about to use OpenHere ? 😉

Run PowerShell with elevated permissions and type:

Install-Module OpenHere
Set-OpenHereShortcut -ShortcutType:WindowsTerminal

👍 who likes this!

It works!! Thank you!

It's way, _way_ easier than that to add a single command to a folder context menu. It's just a simple registry key.

For example (and then you can also add an icon, etc)

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\Open Thing Here\command]
@="C:\\thing.exe \"%1\""

How can I add option to open that thing.exe only when I press SHIFT key - like with the option of "PowerShell Window"

Guys, I know that I'm a little bit late to this party but how about to use OpenHere ? 😉

Run PowerShell with elevated permissions and type:

Install-Module OpenHere
Set-OpenHereShortcut -ShortcutType:WindowsTerminal

👍 who likes this!

How can I remove it?

Guys, I know that I'm a little bit late to this party but how about to use OpenHere ? 😉
Run PowerShell with elevated permissions and type:

Install-Module OpenHere
Set-OpenHereShortcut -ShortcutType:WindowsTerminal

👍 who likes this!

How can I remove it?

From documentation:
Remove-OpenHereShortcut -ShortcutType:WindowsTerminal

Hi all,
I implement a simple script to add context menu.
It work for me with windows terminal version 0.9.433.0
Thank you @nt4f04uNd and other all inspiring me
Repo: Windows-terminal-context-menu

This is really great!!! however few notes:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7
you need to Set-ExecutionPolicy to Unrestricted to run it.

Also, this seems broken:

Copy-Item : The filename, directory name, or volume label syntax is incorrect.
At D:\Jeff\Documents\Windows-terminal-context-menu\SetupContextMenu.ps1:25 char:1
+ Copy-Item -Path "$PSScriptRoot\icons\*.ico" -Destination $resourcePat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand

this dir needs to be created either prior to or as part of the execution:
$env:LOCALAPPDATA\WindowsTerminalContextIcons\

Also, it says:

PS D:\Jeff\Documents\Windows-terminal-context-menu> .\SetupContextMenu.ps1
Add top layer menu (shell) => Registry::HKEY_CLASSES_ROOT\Directory\shell\WindowsTerminal
Add top layer menu (background) => Registry::HKEY_CLASSES_ROOT\Directory\shell\WindowsTerminal
Add new entry Git Bash
Add new entry Command Prompt
Add new entry PowerShell
Add new entry Azure Cloud Shell

but doesn't actually create it properly (Its missing icons and my Git Bash one is missing becuase i dont have the hidden key in it):
image

This scripts has some bugs because is made for an old version of Windows Terminal, i made a fork to fix those errors

https://github.com/KiritoDv/Windows-terminal-context-menu

image

Hi @KiritoDv
Could you check what's your Windows terminal version?
I use latest release version v0.9.433.0 and install successfully.

Thanks~

I have the latest version, but when i update my profiles file are the same from the old profiles version, Sorry for that, at least the change works to someone with the same error

Kuddos Kirito for making the script, it's really nice. Any chance this will be supported by WT in the future?

@RonaldOlsthoorn There's certainly a _chance_ - hence why this issue is still open 😄

If someone could figure out how to install these context menu entries from a packaged application, and be able to update the entries dynamically (to reflect the list of profiles), then we'd certainly be interested in reviewing a PR 😉 Until then, it's just on our backlog.

Maybe the folks who did it for Pengwin could do it for Terminal as well (or at least advise on what they did to get it working).

Hi all,
I implement a simple script to add context menu.
It work for me with windows terminal version 0.9.433.0
Thank you @nt4f04uNd and other all inspiring me
Repo: Windows-terminal-context-menu

This is really great!!! however few notes:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7
you need to Set-ExecutionPolicy to Unrestricted to run it.
Also, this seems broken:

Copy-Item : The filename, directory name, or volume label syntax is incorrect.
At D:\Jeff\Documents\Windows-terminal-context-menu\SetupContextMenu.ps1:25 char:1
+ Copy-Item -Path "$PSScriptRoot\icons\*.ico" -Destination $resourcePat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand

this dir needs to be created either prior to or as part of the execution:
$env:LOCALAPPDATA\WindowsTerminalContextIcons\

Also, it says:

PS D:\Jeff\Documents\Windows-terminal-context-menu> .\SetupContextMenu.ps1
Add top layer menu (shell) => Registry::HKEY_CLASSES_ROOT\Directory\shell\WindowsTerminal
Add top layer menu (background) => Registry::HKEY_CLASSES_ROOT\Directory\shell\WindowsTerminal
Add new entry Git Bash
Add new entry Command Prompt
Add new entry PowerShell
Add new entry Azure Cloud Shell

but doesn't actually create it properly (Its missing icons and my Git Bash one is missing becuase i dont have the hidden key in it):
image

This scripts has some bugs because is made for an old version of Windows Terminal, i made a fork to fix those errors

https://github.com/KiritoDv/Windows-terminal-context-menu

image

Kudos to you for making the script, works like a charm.

Implementation note: The PowerToys app manifest shows how to declare file explorer context menus for files and for folders. I'm not sure if this would require a concommitant COM server registration though...

Note the overlap with #2189 - seems mostly parallel rather than complementary, however.

<Extensions>
        ...
        <com:Extension Category="windows.comServer">
          <com:ComServer>
            <com:ExeServer Executable="modules\PowerRenameUWPUI.exe" DisplayName="PowerRenameUWPUI">
              <com:Class Id="0440049F-D1DC-4E46-B27B-98393D79486B"/>
            </com:ExeServer>
          </com:ComServer>
        </com:Extension>
        <desktop4:Extension Category="windows.fileExplorerContextMenus">
          <desktop4:FileExplorerContextMenus>
            <desktop4:ItemType Type="*">
              <desktop4:Verb Id="FilePowerRename" Clsid="0440049F-D1DC-4E46-B27B-98393D79486B" />
            </desktop4:ItemType>
            <desktop5:ItemType Type="Directory">
              <desktop5:Verb Id="DirectoryPowerRename" Clsid="0440049F-D1DC-4E46-B27B-98393D79486B" />
            </desktop5:ItemType>
          </desktop4:FileExplorerContextMenus>
        </desktop4:Extension>

I have not traced the source code.
Not really sure what's the callback function of profiles.json modified🤔.

Mine worked after spending lots of time to read people comments.😃

Steps to Add "Windows terminal here" into right-click context menu:
1)Download windows terminal from Microsoft store

2)At https://github.com/yanglr/WindowsDevTools/blob/master/awosomeTerminal/icons/wt_32.ico
download icon with file name wt_32.ico

3)Open your CMD and run this command mkdir "%USERPROFILE%\AppData\Local\terminal"

4)Copy the windows terminal icon(that you have downloaded in Step 2) to the folder C:\Users[your-user-name]AppData\Local\terminal
(Example for mine to copy icon: C:\Users\DellAppData\Local\terminal)

5)Open notpad and write below code

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"=C:\\Users\\[your-user-name]\\AppData\\Local\\terminal\\wt_32.ico

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\[your-user-name]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

6) Note:
In [your-user-name] write your user name.
for example my username is Dell my paths will be

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"=C:\\Users\\DELL\\AppData\\Local\\terminal\\wt_32.ico

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\DELL\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

Save file as wt.reg in your Desktop(or anywhere in your PC) and open it
(press OK all)
7)Test it by right click=> Select windows terminal here
[Windows terminal(Preview) will open]👍

It still does not work when add the context menu to drives in File Explorer. It opens WT for a second and then closes it down. Any clues how to resolve this particular issue?

@4k3or3et I'm not sure what are you referring to but the work of @atif-dev and others like @zadjii-msft is quite redundant since there is an Windows PowerShell module that fully covers this including rollback and customization.

@4k3or3et I'm not sure what are you referring to but the work of @atif-dev and others like @zadjii-msft is quite redundant since there is an Windows PowerShell module that fully covers this including rollback and customization.

Similarly like you add context menu items in HKEY_CLASSES_ROOT\Direcroty\shell you can also add them in HKEY_CLASSES_ROOT\Drive\shell. You get then context menu items when you right click on drives in File Explorer.

The problem is that when you add "C:\Users\PROFILE\AppData\Local\Microsoft\WindowsApps\wt.exe -d "%V" -p "Debian" which works in case of folders, it does not for drives in File Explorer. WT then opens for a second and closes down for some reason.

My question is if anyone figured out why Windows Terminal cannot handle the "%V" in case of Drive?

Thank you.

The shortcut should be %V\.

The shortcut should be %V\.

Oh Man! This is awesome!!!

This works for drives and folders...

Would you be that kind and explain to me the "science" behind "%V."? How does it differ from regular "%V"?

So this is one of those "weird issues". "%V" at the drive root expands to "C:\". Most command argument parsers handle \" as ", because \ is the "escape" character. Therefore, it turns the path from "C:\" into C:" (deleting the first quote, and consuming the second).

Using "%V\." makes the drive root expand to "C:\\.", which is totally legal.

So this is one of those "weird issues". "%V" at the drive root expands to "C:\". Most command argument parsers handle \" as ", because \ is the "escape" character. Therefore, it turns the path from "C:\" into C:" (deleting the first quote, and consuming the second).

Using "%V\." makes the drive root expand to "C:\\.", which is totally legal.

Understood. Thanks again for your help.

I have installed it through the store, but Windows tells me "Application not found" when I put wt.exe as the command in the registry key. If I change it to the full path, i.e. %LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe, I get a "cannot access" error (not the correct rights for this item).

Currently I have the command added as cmd.exe /C start wt.exe, and this works, although the old cmd prompt flashes on screen when opening wt.

I have installed it through the store, but Windows tells me "Application not found" when I put wt.exe as the command in the registry key. If I change it to the full path, i.e. %LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe, I get a "cannot access" error (not the correct rights for this item).

Currently I have the command added as cmd.exe /C start wt.exe, and this works, although the old cmd prompt flashes on screen when opening wt.

change through regedit %LOCALAPPDATA% on real address like "C:\Users\[user]AppData\Local"

and then i added this "startingDirectory": "%__CD__%" to profile.json

I have installed it through the store, but Windows tells me "Application not found" when I put wt.exe as the command in the registry key. If I change it to the full path, i.e. %LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe, I get a "cannot access" error (not the correct rights for this item).
Currently I have the command added as cmd.exe /C start wt.exe, and this works, although the old cmd prompt flashes on screen when opening wt.

change through regedit %LOCALAPPDATA% on real address like "C:\Users[user]AppData\Local"

and then i added this "startingDirectory": "%__CD__%" to profile.json

Thanks, it appears this is indeed the correct approach, using the expanded path instead of %LOCALAPPDATA%. I am using "startingDirectory": "." wich also works as expected.

@Wosser1sProductions just use this cmd.exe /s /k pushd "%V" instead of whatever that other command is.

The point is to open the new Windows Terminal (the wt.exe executable) from the context menu. The default value to open the regular command prompt, is indeed cmd.exe /s /k pushd "%V".

Here is a solution.

The bad thing about the reg file is you need to add a specific user wt's path (since UWP installs per-user) in a HKEY_CLASSES_ROOT context. I tried to replace it by HKEY_CURRENT_USER but it doesnt work for me.

IF there's a way to install WT system-wide in a "global" folder it would be a better practice

Let me add my reg file to here, so anyone else can use it:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal Here"
"Icon"="E:\\Resimler\\ico\\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="D:\\WindowsApps\\Microsoft.WindowsTerminal_0.10.781.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"

The first @ is text which will appear on the context menu (_"Windows Terminal Here"_)
"Icon" is the icon path which'll also seen on the context menu.
Second @ is the Terminal exe path. you need to find out where is it.

Customize and paste this code to an txt file and rename it as _wt.reg_. Than run it.

Then open your new windows terminal. Go to Settings:
image

Here we are in the profiles.json
Paste those codes in it:


{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
    "profiles":
    {
        "defaults":
        {
        },
        "list":
        [
            {
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "cmd",
                "commandline": "cmd.exe",
                "hidden": false,
                "startingDirectory": "."
            },
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl"
            }
        ]
    },
    "schemes": [],
    "keybindings": []
}


That's it

here is my registry script, it makes use of the command line arguments. I configred it for CMD, Powershell and WSL Ubuntu default Profile names, with both normal and Admin prompts. It doesn't require any changes to the profiles.json, unlike most of the scripts i've seen in this issue
https://gist.github.com/OmegaRogue/9069405e7b0bf5e76f1c5d9c96f8b663

None of these options are something that I'd be totally happy with. So, I took a stab.

I modified @OmegaRogue's solution. I didn't like the nesting, so I attempted to split the admin and non admin into separate menus.

image

Unfortunately, I cannot figure out how get the admin commands at the same level. This is what I have:
image

Here is my .reg file
I've left some comments to help people figure out which sections do what, so that maybe someone can help fix the admin nesting.

None of these options are something that I'd be totally happy with. So, I took a stab.

I modified @OmegaRogue's solution. I didn't like the nesting, so I attempted to split the admin and non admin into separate menus.

image

Unfortunately, I cannot figure out how get the admin commands at the same level. This is what I have:
image

Here is my .reg file
I've left some comments to help people figure out which sections do what, so that maybe someone can help fix the admin nesting.

I can modify my file to do that and to remove admin nesting

@OmegaRogue Nice one, but I guess the main menu icon will die with a version (and so WindowsTerminal.exe path change). Maybe replacing it with a more universally accessible icon would be better.

Edit : Also if you manage to add admin options (of @t-makaro) without the nesting problem would be great.

Funny, how @lllopo @OmegaRogue @t-makaro @sundowatch and others re-inventing a wheel.

These reg files has same mistakes all over again. They lack the roll back or tests. They aren't working on paths with non-ASCII characters like ě š č ř í é ý é ů or you have to change your Terminal's setting.

Have a look over here instead.

Funny, how @lllopo @OmegaRogue @t-makaro @sundowatch and others re-inventing a wheel.

These reg files has same mistakes all over again. They lack the roll back or tests. They aren't working on paths with non-ASCII characters like ě š č ř í é ý é ů or you have to change your Terminal's setting.

Have a look over here instead.

I know the problem, and the version i use doesn't have it, i just posted this version for readability, my version uses hex(2) encoded text instead of a normal string

People then forget the side affect of if you add "startingDirectory": "." to work with the Registry edit that adds right-click to open in current folder, that now if you just open up the Terminal via start menu, it opens to the system32 directory

People then forget the side affect of if you add "startingDirectory": "." to work with the Registry edit that adds right-click to open in current folder, that now if you just open up the Terminal via start menu, it opens to the system32 directory

which is the reason my script doesn't need that

None of these options are something that I'd be totally happy with. So, I took a stab.

I modified @OmegaRogue's solution. I didn't like the nesting, so I attempted to split the admin and non admin into separate menus.

image

Unfortunately, I cannot figure out how get the admin commands at the same level. This is what I have:
image

Here is my .reg file
I've left some comments to help people figure out which sections do what, so that maybe someone can help fix the admin nesting.

i have added a version of my registry script to the gist that doesn't have nesting:
https://gist.github.com/OmegaRogue/9069405e7b0bf5e76f1c5d9c96f8b663#file-directory_prompts_windowsterminal_nonnested-reg

Did this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal here"
"Icon"="C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminal_0.10.781.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\<user>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d %V"

[HKEY_CLASSES_ROOT\Directory\shell\wt]
@="Windows Terminal here"
"Icon"="C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminal_0.10.781.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"

[HKEY_CLASSES_ROOT\Directory\shell\wt\command]
@="C:\\Users\\<user>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d %V"
  • execute it

Did this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal here"
"Icon"="C:\\Users\\<user>\\AppData\\Local\\Terminal\\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\<user>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d ."

[HKEY_CLASSES_ROOT\Directory\shell\wt]
@="Windows Terminal here"
"Icon"="C:\\Users\\<user>\\AppData\\Local\\Terminal\\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\shell\wt\command]
@="C:\\Users\\<user>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d ."
  • execute it

You don't need to download the icon, you can just use the path of the executable as the icon path, as i did in my registry script

Well, we need to edit reg file each time windows terminal is updated? it's better to store icon file somewhere else

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal here"
"Icon"="C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\user\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d ."

[HKEY_CLASSES_ROOT\Directory\shell\wt]
@="Windows Terminal here"
"Icon"="C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe\\WindowsTerminal.exe"

[HKEY_CLASSES_ROOT\Directory\shell\wt\command]
@="C:\\Users\\user\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d ."

I noticed that right clicking a folder and launching the terminal doesn't work properly, it opens in the container folder.
Came to a solution by replacing wt.exe -d . with wt.exe -d "%V" in the registry script, that's the way VS Code does it.

Here's the fixed registry script I used (no icon)

Edit: Added %V. as suggested, and right click to a drive.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\wt]
@="Open Windows Terminal here"
[HKEY_CLASSES_ROOT\Directory\shell\wt\command]
@="C:\\Users\\user\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d \"%V.\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Open Windows Terminal here"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\user\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d \"%V.\""

[HKEY_CLASSES_ROOT\Drive\shell\wt]
@="Open Windows Terminal here"
[HKEY_CLASSES_ROOT\Drive\shell\wt\command]
@="C:\\Users\\user\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d \"%V.\""

This solution worked great, thank you.

@BealeStBluesBoy and @megapro17 Thank you for your reg file.
I noticed that wt.exe -d \"%V\" does correctly open with selected folder but it does not work when you are in the root of a drive. Example on c: or d:. It opens the terminal but with errorcode 0x8007010b
Also, when you select a drive and run that command, another error appears and the terminal doesn't even open.

However, with wt.exe -d . the terminal does open without problems, doesn't matter where you are. The downside is, it just opens the directory where you currently in, not that directory that you have selected. When you select a drive directly, it just opens in c:\windows\system32 folder.

I'll stick with wt.exe -d . as it always opens a usable terminal.

EDIT:
As @DHowett-MSFT suggested bellow, there is another option wt.exe -d \"%V\.\". This improve the behaviour and does make a terminal open even when you are in the root of a drive. One thing that still does not work with this solution is when you select a drive. This still result in an error.

Offtopic: This issue is a way to big to read each single comment :) Sorry for double posting an issue.

Try "%V\.", as suggested multiple times in this thread.

How do you add a run as admin too?

Can we switch to admin through the terminal ?

Can we switch to admin through the terminal ?

Not right now with vanilla Windows Terminal. Maybe WT v2.0, see #5000. But, there is a workaround: you can use gsudo, an open source Sudo for Windows.
https://github.com/gerardog/gsudo

Since I am the author I feel obligated to warn that it's technically possible that a specially crafted malware could potentially send keystrokes to the sudo'ed console and skip UAC isolation/and escalate privileges.

Speaking of cmd way, there is already a cmd command called runas which asks for the password (similar to sudo).
https://en.wikipedia.org/wiki/Runas

Can we switch to admin through the terminal ?

Not right now with vanilla Windows Terminal. Mayve WT v2.0, see #5000. But, there is a workaround: you can use gsudo, an open source Sudo for Windows.
https://github.com/gerardog/gsudo

Since I am the author I feel obligated to warn that it's technically possible that a specially crafted malware could potentially send keystrokes to the sudo'ed console and skip UAC isolation/and escalate privileges.

What if we check for unwanted access through some security mechanism? Would that work? GSudo is good start.

@BealeStBluesBoy and @megapro17 Thank you for your reg file.
I noticed that wt.exe -d \"%V\" does correctly open with selected folder but it does not work when you are in the root of a drive. Example on c: or d:. It opens the terminal but with errorcode 0x8007010b
Also, when you select a drive and run that command, another error appears and the terminal doesn't even open.

However, with wt.exe -d . the terminal does open without problems, doesn't matter where you are. The downside is, it just opens the directory where you currently in, not that directory that you have selected. When you select a drive directly, it just opens in c:\windows\system32 folder.

I'll stick with wt.exe -d . as it always opens a usable terminal.

EDIT:
As @DHowett-MSFT suggested bellow, there is another option wt.exe -d \"%V\.\". This improve the behaviour and does make a terminal open even when you are in the root of a drive. One thing that still does not work with this solution is when you select a drive. This still result in an error.

Offtopic: This issue is a way to big to read each single comment :) Sorry for double posting an issue.

@brainfoolong There are other problems than just the root of a drive but I've solved all these problems here. ✌

How do you add a run as admin too?

@aminya I turned off UAC and disabled Admin Approval Mode(AAM) like BrainSlugs83 answered in https://superuser.com/questions/462174/winr-runs-as-administrator-in-windows-8.
If you don't care about security problems or whatever side effects it may cause, after doing this Windows Terminal will run as Administrator by default, thus no further settings needed after using registry script above.

I finally fixed the problem 🚀 . Just merge this.

This has the admin button without any security issues.

Generic Reg file

(If you don't have PowerShellCore, this is slower):

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Open Windows Terminal Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process wt.exe -ArgumentList \\\"-d\\\",\\\"%V.\\\"\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt_admin]
@="Open Windows Terminal Here as Admin"
"Icon"="cmd.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt_admin\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process wt.exe -ArgumentList \\\"-d\\\",\\\"%V.\\\" -Verb RunAs\""

[HKEY_CLASSES_ROOT\Directory\shell\wt]
@="Open Windows Terminal Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\shell\wt\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process wt.exe -ArgumentList \\\"-d\\\",\\\"%V.\\\"\""


[HKEY_CLASSES_ROOT\Directory\shell\wt_admin]
@="Open Windows Terminal Here as Admin"
"Icon"="cmd.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\shell\wt_admin\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process wt.exe -ArgumentList \\\"-d\\\",\\\"%V.\\\" -Verb RunAs\""

Faster Reg File

(If you have PowerShellCore)

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Open Windows Terminal Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="pwsh -windowstyle hidden -Command \"Start-Process wt.exe -ArgumentList \\\"-d\\\",\\\"%V.\\\"\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt_admin]
@="Open Windows Terminal Here as Admin"
"Icon"="cmd.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt_admin\command]
@="pwsh -windowstyle hidden -Command \"Start-Process wt.exe -ArgumentList \\\"-d\\\",\\\"%V.\\\" -Verb RunAs\""

[HKEY_CLASSES_ROOT\Directory\shell\wt]
@="Open Windows Terminal Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\shell\wt\command]
@="pwsh -windowstyle hidden -Command \"Start-Process wt.exe -ArgumentList \\\"-d\\\",\\\"%V.\\\"\""


[HKEY_CLASSES_ROOT\Directory\shell\wt_admin]
@="Open Windows Terminal Here as Admin"
"Icon"="cmd.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\shell\wt_admin\command]
@="pwsh -windowstyle hidden -Command \"Start-Process wt.exe -ArgumentList \\\"-d\\\",\\\"%V.\\\" -Verb RunAs\""

You can download the icon from here and replace its download path (escape \) with cmd.exe:
https://raw.githubusercontent.com/microsoft/terminal/master/res/terminal.ico

@aminya admin mode doesn't work for me at all. -windowstyle hidden seems to be ignored too

@aminya admin mode doesn't work for me at all.

You may need to restart explorer.exe

-windowstyle hidden seems to be ignored too

It shows the windows for a moment.

some of the admin scripts don't work for me, I am not sure why, but I have noticed that git bash (speaking of which vscode seem to have lots of open with vs code entry points scattered in the registry) shows in more menus than some of the solutions offer so I created a simplified version of @OmegaRogue's
this uses "%USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wt.exe" "-d" "." as the command, as suggested
https://gist.github.com/YoraiLevi/283532872b26b93e562b04812821db25

Windows Registry Editor Version 5.00

;drive
[HKEY_CLASSES_ROOT\Drive\shell\wt]
@="Open Windows Terminal Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Drive\shell\wt\command]
@=hex(2):22,00,25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
  00,45,00,25,00,5c,00,41,00,70,00,70,00,44,00,61,00,74,00,61,00,5c,00,4c,00,\
  6f,00,63,00,61,00,6c,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,\
  00,74,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,41,00,70,00,70,00,\
  73,00,5c,00,77,00,74,00,2e,00,65,00,78,00,65,00,22,00,20,00,22,00,2d,00,64,\
  00,22,00,20,00,22,00,2e,00,22,00,00,00
;end drive


;background 1
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\wt]
@="Open Windows Terminal Here"
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\wt\command]
@=hex(2):22,00,25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
  00,45,00,25,00,5c,00,41,00,70,00,70,00,44,00,61,00,74,00,61,00,5c,00,4c,00,\
  6f,00,63,00,61,00,6c,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,\
  00,74,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,41,00,70,00,70,00,\
  73,00,5c,00,77,00,74,00,2e,00,65,00,78,00,65,00,22,00,20,00,22,00,2d,00,64,\
  00,22,00,20,00,22,00,2e,00,22,00,00,00
;end background 1

;libary folders, like what git does
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\wt]
@="Open Windows Terminal Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\wt\command]
@=hex(2):22,00,25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
  00,45,00,25,00,5c,00,41,00,70,00,70,00,44,00,61,00,74,00,61,00,5c,00,4c,00,\
  6f,00,63,00,61,00,6c,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,\
  00,74,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,41,00,70,00,70,00,\
  73,00,5c,00,77,00,74,00,2e,00,65,00,78,00,65,00,22,00,20,00,22,00,2d,00,64,\
  00,22,00,20,00,22,00,2e,00,22,00,00,00
;end library folders 

;background 2
[HKEY_CLASSES_ROOT\Directory\background\shell\wt]
@="Open Windows Terminal Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\background\shell\wt\command]
@=hex(2):22,00,25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,\
  00,45,00,25,00,5c,00,41,00,70,00,70,00,44,00,61,00,74,00,61,00,5c,00,4c,00,\
  6f,00,63,00,61,00,6c,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,\
  00,74,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,41,00,70,00,70,00,\
  73,00,5c,00,77,00,74,00,2e,00,65,00,78,00,65,00,22,00,20,00,22,00,2d,00,64,\
  00,22,00,20,00,22,00,2e,00,22,00,00,00
;end background 2

I just created two PowerShell scripts for install/uninstall the context menu items, and shared them on GitHub at

https://github.com/lextm/windowsterminal-shell

The logic is similar to what @nerdio01 proposed, but the menu layout is slightly different (update: now multiple layouts are supported).

image

With install.ps1 and uninstall.ps1, you no longer need to import registry key files and wonder how to delete them if you don't like.

Pull requests are welcome.

A bit annoying that the icon is in a versioned path, is there a better way to reference to it apart from just shipping my one?

The way I see it, having to manually edit the registry isn't an ideal solution. Part of the selling points of this project is that it supports several kinds of shells (pwsh, cmd, ubuntu, whatever else) and this list can vary from user to user. A fixed registry script won't cut it.
One would also have to remember to manually remove the changes made to the registry when uninstalling Windows Terminal.

Is there a specific design/technical consideration/limitation that would block this feature from being built into Windows Terminal itself? Or is it more a matter of manpower, priorities and time?

manpower, priorities and time

Definitely that one. If I had all the engineering time to spend I’d want to offer an actual shell extension that detected your profiles and displayed them in a menu, and let you spawn shells in already-running instances of Terminal.

After giving it some thought, I think there might be a simpler way to approach this. What if there was only a single static entry in the context menu, which when clicked would open Windows Terminal where they are then prompted to select a profile.

This would remove the need for maintaining a dynamic set of registry keys. And make it so that the settings file doesn't need to be parsed and checked for profile changes on every right click.

I haven't familiarized myself with the codebase of this project, so I can't say for sure if that would reduce the amount of work needed to implement this. But I'd like to hear your thoughts on that.

just type wt in addressbar in windows explorer in any folder and hit enter

If anyone tried @llevo3 tip of typing wt in the explorer address bar like you would with cmd is not working for you.

Then ensure the following is in your PATH environment variable
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps

just type wt in addressbar in windows explorer in any folder and hit enter

@llevo3 this doesn't open the windows terminal in the current directory. Rather it opens with the default directory.

@abdulghanitech this extremely specific problem has been discussed no fewer than 30 times in this thread. 😄

just type wt in addressbar in windows explorer in any folder and hit enter

@llevo3 this doesn't open the windows terminal in the current directory. Rather it opens with the default directory.

if you want to open current directory, just use -d option in front of the address
ex
wt -d [path you want to go]

To clarify, you can open the current directory by typing wt -d .

Q: Once the terminal is opened with wt -d ., is there a way to use that same path for new terminal instances (tab/pane)?

Thank you to everyone who commented a solution and different approaches to apply this correctly. I got it working with Console 2. Using the "Open here" with the flag -d . worked prefect.

Excuse me how can i fix this

image

Dude, don’t come on to an unrelated thread to ask a question. File a new bug and the team can look at it 😄

@miniksa @zadjii-msft @DHowett-MSFT @factormystic @ChrisGuzak

I solved the issue now, it could be closed. Thanks a lot to all who involved into this discussion.

Step 0:

Test if two constants below works well which will be used in following other steps.

echo %USERPROFILE%

echo %LOCALAPPDATA%

If everything works well here, then these two constants can be used directly in other below steps.

Or please perform following replacements in below steps:

%USERPROFILE% → C:\Users\[userName]
%LOCALAPPDATA% → C:\Users\[userName]\AppData\Local

Here [userName] represents your user name,for instance, mine is Bruce.

Step 1:
Run below stuff in CMD:

mkdir "%USERPROFILE%\AppData\Local\terminal"

image

Step 2:
Copy the windows terminal icon to the folder %USERPROFILE%\AppData\Local\terminal, the icon can be obtained in https://github.com/yanglr/WindowsDevTools/tree/master/awosomeTerminal/icons whose file name is wt_32.ico.

Step 3:
Save follwing content as wt.reg, then run as administrator.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt_32.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"

To be noted, if the exe obtained after building code by yourself is wtd.exe, you need to change the above wt.exe to wtd.exe in the above registry.

Step 4:
Test
image

I had a problem with this solution, some permission issues, if it can help someone
replace
@="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"
with
@="C:\\Users\\YOURUSERNAME\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d ."

From my understanding, percent-encoded environment-variables must use the expandable string type (REG_EXPAND_SZ) in order to be correctly interpreted which is why I believe some of the other solutions don't fully work1. I created the below Registry script which uses expandable strings so you don't have to change the username however, you probably want to change the icon path.

I also added an action/option to open as an administrator.

Windows Registry Editor Version 5.00

;Binary data is just UTF16 (LE) split every 2 bytes with a comma
;Conversion done with https://onlineutf8tools.com/convert-utf8-to-utf16?hex=true&little-endian=true&space=false&chain=split-string%253Fsplit-by-length%253Dtrue%2526separator%253D%252C

;User action
[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminal]
@="Open Terminal here"
;"Icon"="%USERPROFILE%\Pictures\Icons\terminal.ico" (Location to ICO or comment out to hide icon)
"Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,00,45,00,25,00,5c,00,50,00,69,00,63,00,74,00,75,00,72,00,65,00,73,00,5c,00,49,00,63,00,6f,00,6e,00,73,00,5c,00,74,00,65,00,72,00,6d,00,69,00,6e,00,61,00,6c,00,2e,00,69,00,63,00,6f,00

;User action command
[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminal\command]
;@="%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe -d ."
@=hex(2):25,00,4c,00,4f,00,43,00,41,00,4c,00,41,00,50,00,50,00,44,00,41,00,54,00,41,00,25,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,41,00,70,00,70,00,73,00,5c,00,77,00,74,00,2e,00,65,00,78,00,65,00,20,00,2d,00,64,00,20,00,2e,00

;Admin action
[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminalAdmin]
@="Open Terminal here (Admin)"
;Show the UAC shield on the action
"HasLUAShield"=""
;"Icon"="%USERPROFILE%\Pictures\Icons\terminal.ico" (Location to ICO or comment out to hide icon)
"Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,00,45,00,25,00,5c,00,50,00,69,00,63,00,74,00,75,00,72,00,65,00,73,00,5c,00,49,00,63,00,6f,00,6e,00,73,00,5c,00,74,00,65,00,72,00,6d,00,69,00,6e,00,61,00,6c,00,2e,00,69,00,63,00,6f,00

;Admin action command
[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminalAdmin\command]
@="PowerShell -WindowStyle Hidden -Command \"Start-Process wt -ArgumentList '-d','.' -Verb runAs\""
  1. https://superuser.com/a/599025

From my understanding, percent-encoded environment-variables must use the expandable string type (REG_EXPAND_SZ) in order to be correctly interpreted which is why I believe some of the other solutions don't _fully_ work1. I created the below Registry script which uses expandable strings so you don't have to change the username however, you probably want to change the icon path.

I also added an action/option to open as an administrator.

Windows Registry Editor Version 5.00

;Binary data is just UTF16 (LE) split every 2 bytes with a comma
;Conversion done with https://onlineutf8tools.com/convert-utf8-to-utf16?hex=true&little-endian=true&space=false&chain=split-string%253Fsplit-by-length%253Dtrue%2526separator%253D%252C

;User action
[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminal]
@="Open Terminal here"
;"Icon"="%USERPROFILE%\Pictures\Icons\terminal.ico" (Location to ICO or comment out to hide icon)
"Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,00,45,00,25,00,5c,00,50,00,69,00,63,00,74,00,75,00,72,00,65,00,73,00,5c,00,49,00,63,00,6f,00,6e,00,73,00,5c,00,74,00,65,00,72,00,6d,00,69,00,6e,00,61,00,6c,00,2e,00,69,00,63,00,6f,00

;User action command
[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminal\command]
;@="%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe -d ."
@=hex(2):25,00,4c,00,4f,00,43,00,41,00,4c,00,41,00,50,00,50,00,44,00,41,00,54,00,41,00,25,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,41,00,70,00,70,00,73,00,5c,00,77,00,74,00,2e,00,65,00,78,00,65,00,20,00,2d,00,64,00,20,00,2e,00

;Admin action
[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminalAdmin]
@="Open Terminal here (Admin)"
;Show the UAC shield on the action
"HasLUAShield"=""
;"Icon"="%USERPROFILE%\Pictures\Icons\terminal.ico" (Location to ICO or comment out to hide icon)
"Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,00,45,00,25,00,5c,00,50,00,69,00,63,00,74,00,75,00,72,00,65,00,73,00,5c,00,49,00,63,00,6f,00,6e,00,73,00,5c,00,74,00,65,00,72,00,6d,00,69,00,6e,00,61,00,6c,00,2e,00,69,00,63,00,6f,00

;Admin action command
[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminalAdmin\command]
@="PowerShell -WindowStyle Hidden -Command \"Start-Process wt -ArgumentList '-d','.' -Verb runAs\""
  1. https://superuser.com/a/599025

Hey thanks for this, I didn't end up using this because it pops up a Windows PowerShell window when launching in an elevated fashion however it got me to look deeper into this and I've made my own repository with an easy install script for anyone else who desires context menu entries for Windows Terminal.

For future readers of this long thread,

  • Microsoft decided to include its own Windows Explorer context menu items. That's why this issue was closed. However, due to their release cycle this won't land on your machine (via Microsoft Store for Windows 10) in a few weeks (or months). So far, they developed a simple shell extension with some core functionality.
  • If you really need context menus at this moment, you have to add such menu items on your own using one of the methods in this long thread. To summarize,

    • Import registry keys.
    • Use some batch files. (like this)
    • Use some PowerShell scripts. (like this)

Whatever you choose, report issues to the owners of those repo so they can fix them.

  • However, due to their release cycle this won't land on your machine (via Microsoft Store for Windows 10) in a few weeks (or months)

Oh it'll definitely be sooner than months 😉

:tada:This issue was addressed in #6100, which has now been successfully released as Windows Terminal Preview v1.1.1671.0.:tada:

Handy links:

Shouldn't the Store Download link to Windows Terminal Preview (https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)? 🤔

@DHowett oh no, we'll need to update the bot

Seems as though I'll still be using my batch script for now as the vanilla one doesn't include an elevated option, I'm sure with more time the vanilla version will get more options and or features though, big thanks to the guy who submitted the pull request!

Huh, we absolutely will need to update the bot. Lol.

Sorry for the off topic message, but if you have installed both the release version and the preview one, which would be invoked when running wt?

I'm guessing whatever you have set in App execution aliases in Windows's settings:
image

Yep.

Would be nice if the terminal icon was included as well in the context menu

Would be nice if the terminal icon was included as well in the context menu

Hey wadda ya know, that's #6246.

Please for the love of everyone else on this issue (all 111 of you), please check these issues:
https://github.com/microsoft/terminal/issues?q=is%3Aopen+is%3Aissue+label%3AArea-ShellExtension

before commenting on "man it'd be cool if the context menu did..."

Shouldn't the Store Download link to Windows Terminal Preview (microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)? 🤔

@DHowett oh no, we'll need to update the bot

Huh, we absolutely will need to update the bot. Lol.

Got it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

privacyguy123 picture privacyguy123  ·  131Comments

CobusKruger picture CobusKruger  ·  60Comments

dhavalhirdhav picture dhavalhirdhav  ·  56Comments

pingzing picture pingzing  ·  212Comments

Ronkiro picture Ronkiro  ·  65Comments