Context Menu command to open Ubuntu in Terminal from current director doesn't work #19778

Closed
opened 2026-01-31 06:53:20 +00:00 by claunia · 3 comments
Owner

Originally created by @davidfufu on GitHub (Apr 28, 2023).

Windows Terminal version

1.16.10261.0

Windows build number

Windows 10 Enterprise LTSC
21H2
Build: 19044.2846

Other Software

No response

Steps to reproduce

I have this .reg file to create a context menu shortcut to open Terminal profiles from the current context. The Ubuntu one is opening, but not opening it at the current directory.

Windows Registry Editor Version 5.00

; Directory

[HKEY_CLASSES_ROOT\Directory\shell\WindowsTerminalAsAdmin]
"HasLUAShield"=""
"MUIVerb"="Open in Windows Terminal as Administrator"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile]
"MUIVerb"="Open in Windows Terminal as Administrator - Default Profile"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile\command]
@="powershell.exe -WindowStyle Hidden "Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-d','.')""

[HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\02Cmd]
"MUIVerb"="Open in Windows Terminal as Administrator - Command Prompt"
"Icon"="imageres.dll,-5324"

[HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\02Cmd\command]
@="powershell.exe -WindowStyle Hidden "Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','"""Command Prompt"""','-d','.')""

[HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\03PS]
"MUIVerb"="Open in Windows Terminal as Administrator - PowerShell"
"HasLUAShield"=""
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\03PS\command]
@="powershell.exe -WindowStyle Hidden "Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','"""Windows PowerShell"""','-d','.')""

[HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\04Ubuntu]
"MUIVerb"="Open in Windows Terminal as Administrator - Ubuntu"
"HasLUAShield"=""
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\04Ubuntu\command]
@="cmd.exe /c start wt.exe -p "Ubuntu 22.04.2 LTS" -d "%1""

; Directory\Background

[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminalAsAdmin]
"HasLUAShield"=""
"MUIVerb"="Open in Windows Terminal as Administrator"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile]
"MUIVerb"="Open in Windows Terminal as Administrator - Default Profile"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile\command]
@="powershell.exe -WindowStyle Hidden "Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-d','.')""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\02Cmd]
"MUIVerb"="Open in Windows Terminal as Administrator - Command Prompt"
"Icon"="imageres.dll,-5324"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\02Cmd\command]
@="powershell.exe -WindowStyle Hidden "Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','"""Command Prompt"""','-d','.')""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\03PS]
"MUIVerb"="Open in Windows Terminal as Administrator - PowerShell"
"HasLUAShield"=""
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\03PS\command]
@="powershell.exe -WindowStyle Hidden "Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','"""Windows PowerShell"""','-d','.')""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\04Ubuntu]
"MUIVerb"="Ubuntu 22.04.2 LTS"
"Icon"="wsl.exe"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\04Ubuntu\command]
@="cmd.exe /c start wt.exe -p "Ubuntu 22.04.2 LTS" -d "%V""
`

Expected Behavior

I'm expecting a new Ubuntu shell window in Terminal opened at the directory I opened the context menu at.

Actual Behavior

Instead, what I get is a Ubuntu window in terminal at ~/

Originally created by @davidfufu on GitHub (Apr 28, 2023). ### Windows Terminal version 1.16.10261.0 ### Windows build number Windows 10 Enterprise LTSC 21H2 Build: 19044.2846 ### Other Software _No response_ ### Steps to reproduce I have this .reg file to create a context menu shortcut to open Terminal profiles from the current context. The Ubuntu one is opening, but not opening it at the current directory. Windows Registry Editor Version 5.00 ; Directory [HKEY_CLASSES_ROOT\Directory\shell\WindowsTerminalAsAdmin] "HasLUAShield"="" "MUIVerb"="Open in Windows Terminal as Administrator" "SubCommands"="" [HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile] "MUIVerb"="Open in Windows Terminal as Administrator - Default Profile" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile\command] @="powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-d','.')\"" [HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\02Cmd] "MUIVerb"="Open in Windows Terminal as Administrator - Command Prompt" "Icon"="imageres.dll,-5324" [HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\02Cmd\command] @="powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','\"\"\"Command Prompt\"\"\"','-d','.')\"" [HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\03PS] "MUIVerb"="Open in Windows Terminal as Administrator - PowerShell" "HasLUAShield"="" "Icon"="powershell.exe" [HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\03PS\command] @="powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','\"\"\"Windows PowerShell\"\"\"','-d','.')\"" [HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\04Ubuntu] "MUIVerb"="Open in Windows Terminal as Administrator - Ubuntu" "HasLUAShield"="" "Icon"="powershell.exe" [HKEY_CLASSES_ROOT\Directory\Shell\WindowsTerminalAsAdmin\shell\04Ubuntu\command] @="cmd.exe /c start wt.exe -p \"Ubuntu 22.04.2 LTS\" -d \"%1\"" ; Directory\Background [HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminalAsAdmin] "HasLUAShield"="" "MUIVerb"="Open in Windows Terminal as Administrator" "SubCommands"="" [HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile] "MUIVerb"="Open in Windows Terminal as Administrator - Default Profile" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\01defaultProfile\command] @="powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-d','.')\"" [HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\02Cmd] "MUIVerb"="Open in Windows Terminal as Administrator - Command Prompt" "Icon"="imageres.dll,-5324" [HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\02Cmd\command] @="powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','\"\"\"Command Prompt\"\"\"','-d','.')\"" [HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\03PS] "MUIVerb"="Open in Windows Terminal as Administrator - PowerShell" "HasLUAShield"="" "Icon"="powershell.exe" [HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\03PS\command] @="powershell.exe -WindowStyle Hidden \"Set-Location -literalPath '%V';Start-Process -Verb RunAs wt.exe -ArgumentList @('-p','\"\"\"Windows PowerShell\"\"\"','-d','.')\"" [HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\04Ubuntu] "MUIVerb"="Ubuntu 22.04.2 LTS" "Icon"="wsl.exe" [HKEY_CLASSES_ROOT\Directory\Background\Shell\WindowsTerminalAsAdmin\shell\04Ubuntu\command] @="cmd.exe /c start wt.exe -p \"Ubuntu 22.04.2 LTS\" -d \"%V\"" ` ### Expected Behavior I'm expecting a new Ubuntu shell window in Terminal opened at the directory I opened the context menu at. ### Actual Behavior Instead, what I get is a Ubuntu window in terminal at ~/
claunia added the Needs-TriageIssue-BugNeeds-Attention labels 2026-01-31 06:53:20 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Apr 28, 2023):

I suspect this is a different version of #12961. Is the commandline for your "Ubuntu 22.04.2 LTS" profile wsl -d <something>, or is it ubuntu.exe/?

The former should respect the -d param. The latter doesn't.

@zadjii-msft commented on GitHub (Apr 28, 2023): I suspect this is a different version of #12961. Is the commandline for your "Ubuntu 22.04.2 LTS" profile `wsl -d <something>`, or is it `ubuntu.exe`/? The former should respect the `-d` param. The latter doesn't.
Author
Owner

@jamespack commented on GitHub (Apr 30, 2023):

If you change the command for the profile to wsl.exe Ubuntu-22.04 I bet it would work.
image

@jamespack commented on GitHub (Apr 30, 2023): If you change the command for the profile to wsl.exe Ubuntu-22.04 I bet it would work. <img width="428" alt="image" src="https://user-images.githubusercontent.com/2086722/235366581-0058dccc-7104-4157-a176-4ae253aa6076.png">
Author
Owner

@davidfufu commented on GitHub (Apr 30, 2023):

I have fixed the issue and created a repo with my context menu .reg files in case anyone wants to install it as well.

https://github.com/davidfufu/OpenWTProfilesViaContextMenu

The solution was to just use wsl.exe profile instead of the Ubuntu 22.04.2 LTS one.

Command line ended up being:

"commandline": "C:\\WINDOWS\\system32\\wsl.exe -d Ubuntu-22.04",

@davidfufu commented on GitHub (Apr 30, 2023): I have fixed the issue and created a repo with my context menu .reg files in case anyone wants to install it as well. https://github.com/davidfufu/OpenWTProfilesViaContextMenu The solution was to just use wsl.exe profile instead of the Ubuntu 22.04.2 LTS one. Command line ended up being: `"commandline": "C:\\WINDOWS\\system32\\wsl.exe -d Ubuntu-22.04",`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19778