Improve behavior when calling wt.exe to open to a folder #20665

Closed
opened 2026-01-31 07:20:31 +00:00 by claunia · 13 comments
Owner

Originally created by @Stanzilla on GitHub (Oct 13, 2023).

Description of the new feature/enhancement

Currently when you do something like wt.exe -p "Windows PowerShell" -d folder\path and already have a terminal open, it hides and then re-shows instead of just opening a new tab. See video below.

https://github.com/microsoft/terminal/assets/75278/9499ed68-cb3d-4c86-a0ce-719acdfea02f

Proposed technical implementation details (optional)

Open the tab directly instead of doing the hide/show/flash

Originally created by @Stanzilla on GitHub (Oct 13, 2023). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement Currently when you do something like `wt.exe -p "Windows PowerShell" -d folder\path` and already have a terminal open, it hides and then re-shows instead of just opening a new tab. See video below. https://github.com/microsoft/terminal/assets/75278/9499ed68-cb3d-4c86-a0ce-719acdfea02f <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) Open the tab directly instead of doing the hide/show/flash <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@zadjii-msft commented on GitHub (Oct 13, 2023):

.... what

I'm definitely not seeing this. What version are you on? Could you share your settings.json file/?

We shouldn't be doing any sort of show/hide dance there 🙃

@zadjii-msft commented on GitHub (Oct 13, 2023): .... what I'm definitely not seeing this. What version are you on? Could you share your [settings.json file](https://github.com/microsoft/terminal/wiki/Frequently-Asked-Questions-(FAQ)#where-can-i-find-the-settings-file)/? We shouldn't be doing any sort of show/hide dance there 🙃
Author
Owner

@Stanzilla commented on GitHub (Oct 13, 2023):

.... what

I'm definitely not seeing this. What version are you on? Could you share your settings.json file/?

We shouldn't be doing any sort of show/hide dance there 🙃

Here you go! https://gist.github.com/Stanzilla/f4e17a26df66879914e35dbc0fbc3f1b

it's 1.19.2682.0 but it has been happening for ...ages, I just never bothered to report it

The context menu integration is this, https://winaero.com/add-open-in-windows-terminal-cascading-context-menu-in-windows-10/ which (according to the website) just calls wt.exe like I mentioned above.

@Stanzilla commented on GitHub (Oct 13, 2023): > .... what > > I'm definitely not seeing this. What version are you on? Could you share your [settings.json file](https://github.com/microsoft/terminal/wiki/Frequently-Asked-Questions-(FAQ)#where-can-i-find-the-settings-file)/? > > We shouldn't be doing any sort of show/hide dance there 🙃 Here you go! https://gist.github.com/Stanzilla/f4e17a26df66879914e35dbc0fbc3f1b it's 1.19.2682.0 but it has been happening for ...ages, I just never bothered to report it The context menu integration is this, https://winaero.com/add-open-in-windows-terminal-cascading-context-menu-in-windows-10/ which (according to the website) just calls wt.exe like I mentioned above.
Author
Owner

@carlos-zamora commented on GitHub (Oct 24, 2023):

Can you run that command in the address bar of File Explorer? Does it exhibit the same behavior?

Also, does this happen for the Command Prompt profile?

@carlos-zamora commented on GitHub (Oct 24, 2023): Can you run that command in the address bar of File Explorer? Does it exhibit the same behavior? Also, does this happen for the Command Prompt profile?
Author
Owner

@Stanzilla commented on GitHub (Oct 24, 2023):

Can you run that command in the address bar of File Explorer? Does it exhibit the same behavior?

Also, does this happen for the Command Prompt profile?

It does not happen from the address bar, it does happen with the cmd profile (not from progress bar)

@Stanzilla commented on GitHub (Oct 24, 2023): > Can you run that command in the address bar of File Explorer? Does it exhibit the same behavior? > > Also, does this happen for the Command Prompt profile? It does not happen from the address bar, it does happen with the cmd profile (not from progress bar)
Author
Owner

@zadjii-msft commented on GitHub (Oct 24, 2023):

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\OpenWindowsTerminalProfiles]
"MUIVerb"="Open in Windows Terminal"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile]
"MUIVerb"="Default Profile"

[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile\command]
@="cmd.exe /c start wt.exe -d \"%1\""


[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile]
"MUIVerb"="Command Prompt"
"Icon"="imageres.dll,-5323"

[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile\command]
@="cmd.exe /c start wt.exe -p \"Command Prompt\" -d \"%1\""


[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile]
"MUIVerb"="PowerShell"
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile\command]
@="cmd.exe /c start wt.exe -p \"Windows PowerShell\" -d \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWindowsTerminalProfiles]
"MUIVerb"="Open in Windows Terminal"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile]
"MUIVerb"="Default Profile"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile\command]
@="cmd.exe /c start wt.exe -d \"%V\""


[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile]
"MUIVerb"="Command Prompt"
"Icon"="imageres.dll,-5323"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile\command]
@="cmd.exe /c start wt.exe -p \"Command Prompt\" -d \"%V\""


[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile]
"MUIVerb"="PowerShell"
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile\command]
@="cmd.exe /c start wt.exe -p \"Windows PowerShell\" -d \"%V\""

well, that sorta explains it. It's definitely not just calling wt -d . -p "the profile". It's shelling out to another cmd.exe (which, in this case appears to glom onto your first window). That cmd.exe briefly appears as a tab, then calls wt to open a new tab. Mental.

Wacky that it seems to minimize and restore as the original cmd.exe tab exits, then the new tab opens. I wonder if File Explorer is playing weird games as you launch/close things from context menus?

@zadjii-msft commented on GitHub (Oct 24, 2023): ```reg Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\OpenWindowsTerminalProfiles] "MUIVerb"="Open in Windows Terminal" "SubCommands"="" [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile] "MUIVerb"="Default Profile" [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile\command] @="cmd.exe /c start wt.exe -d \"%1\"" [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile] "MUIVerb"="Command Prompt" "Icon"="imageres.dll,-5323" [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile\command] @="cmd.exe /c start wt.exe -p \"Command Prompt\" -d \"%1\"" [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile] "MUIVerb"="PowerShell" "Icon"="powershell.exe" [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile\command] @="cmd.exe /c start wt.exe -p \"Windows PowerShell\" -d \"%1\"" [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWindowsTerminalProfiles] "MUIVerb"="Open in Windows Terminal" "SubCommands"="" [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile] "MUIVerb"="Default Profile" [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile\command] @="cmd.exe /c start wt.exe -d \"%V\"" [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile] "MUIVerb"="Command Prompt" "Icon"="imageres.dll,-5323" [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile\command] @="cmd.exe /c start wt.exe -p \"Command Prompt\" -d \"%V\"" [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile] "MUIVerb"="PowerShell" "Icon"="powershell.exe" [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile\command] @="cmd.exe /c start wt.exe -p \"Windows PowerShell\" -d \"%V\"" ``` well, that sorta explains it. It's definitely _not_ just calling `wt -d . -p "the profile"`. It's shelling out to _another_ cmd.exe (which, in this case appears to glom onto your first window). That cmd.exe briefly appears as a tab, then calls `wt` to open a new tab. Mental. Wacky that it seems to minimize and restore as the original cmd.exe tab exits, then the new tab opens. I wonder if File Explorer is playing weird games as you launch/close things from context menus?
Author
Owner

@Stanzilla commented on GitHub (Oct 24, 2023):

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\OpenWindowsTerminalProfiles]
"MUIVerb"="Open in Windows Terminal"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile]
"MUIVerb"="Default Profile"

[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile\command]
@="cmd.exe /c start wt.exe -d \"%1\""


[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile]
"MUIVerb"="Command Prompt"
"Icon"="imageres.dll,-5323"

[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile\command]
@="cmd.exe /c start wt.exe -p \"Command Prompt\" -d \"%1\""


[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile]
"MUIVerb"="PowerShell"
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile\command]
@="cmd.exe /c start wt.exe -p \"Windows PowerShell\" -d \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWindowsTerminalProfiles]
"MUIVerb"="Open in Windows Terminal"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile]
"MUIVerb"="Default Profile"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile\command]
@="cmd.exe /c start wt.exe -d \"%V\""


[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile]
"MUIVerb"="Command Prompt"
"Icon"="imageres.dll,-5323"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile\command]
@="cmd.exe /c start wt.exe -p \"Command Prompt\" -d \"%V\""


[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile]
"MUIVerb"="PowerShell"
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile\command]
@="cmd.exe /c start wt.exe -p \"Windows PowerShell\" -d \"%V\""

well, that sorta explains it. It's definitely not just calling wt -d . -p "the profile". It's shelling out to another cmd.exe (which, in this case appears to glom onto your first window). That cmd.exe briefly appears as a tab, then calls wt to open a new tab. Mental.

Wacky that it seems to minimize and restore as the original cmd.exe tab exits, then the new tab opens. I wonder if File Explorer is playing weird games as you launch/close things from context menus?

Oh damn, guess that should be mentioned in their docs. From the looks of it, it should just work when removing the cmd call before?

@Stanzilla commented on GitHub (Oct 24, 2023): > ```reg > Windows Registry Editor Version 5.00 > > [HKEY_CLASSES_ROOT\Directory\shell\OpenWindowsTerminalProfiles] > "MUIVerb"="Open in Windows Terminal" > "SubCommands"="" > > [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile] > "MUIVerb"="Default Profile" > > [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile\command] > @="cmd.exe /c start wt.exe -d \"%1\"" > > > [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile] > "MUIVerb"="Command Prompt" > "Icon"="imageres.dll,-5323" > > [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile\command] > @="cmd.exe /c start wt.exe -p \"Command Prompt\" -d \"%1\"" > > > [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile] > "MUIVerb"="PowerShell" > "Icon"="powershell.exe" > > [HKEY_CLASSES_ROOT\Directory\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile\command] > @="cmd.exe /c start wt.exe -p \"Windows PowerShell\" -d \"%1\"" > > [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWindowsTerminalProfiles] > "MUIVerb"="Open in Windows Terminal" > "SubCommands"="" > > [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile] > "MUIVerb"="Default Profile" > > [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\01DefaultProfile\command] > @="cmd.exe /c start wt.exe -d \"%V\"" > > > [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile] > "MUIVerb"="Command Prompt" > "Icon"="imageres.dll,-5323" > > [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\02CommandPromptProfile\command] > @="cmd.exe /c start wt.exe -p \"Command Prompt\" -d \"%V\"" > > > [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile] > "MUIVerb"="PowerShell" > "Icon"="powershell.exe" > > [HKEY_CLASSES_ROOT\Directory\Background\Shell\OpenWindowsTerminalProfiles\shell\03PowerShellProfile\command] > @="cmd.exe /c start wt.exe -p \"Windows PowerShell\" -d \"%V\"" > ``` > > well, that sorta explains it. It's definitely _not_ just calling `wt -d . -p "the profile"`. It's shelling out to _another_ cmd.exe (which, in this case appears to glom onto your first window). That cmd.exe briefly appears as a tab, then calls `wt` to open a new tab. Mental. > > Wacky that it seems to minimize and restore as the original cmd.exe tab exits, then the new tab opens. I wonder if File Explorer is playing weird games as you launch/close things from context menus? Oh damn, guess that should be mentioned in their docs. From the looks of it, it should just work when removing the cmd call before?
Author
Owner

@zadjii-msft commented on GitHub (Oct 24, 2023):

I'd guess as much?

@zadjii-msft commented on GitHub (Oct 24, 2023): I'd guess as much?
Author
Owner

@Stanzilla commented on GitHub (Oct 25, 2023):

I heard back from Winaero:

The reason why we have there cmd.exe is that WT.EXE is not a "true" binary file. It is an alias. It can point to Windows Terminal or to its Preview version. You cannot call an alias from the Registry. This will fail. The context menu doesn't recognize aliases. This is why I used the start command.

@Stanzilla commented on GitHub (Oct 25, 2023): I heard back from Winaero: > The reason why we have there cmd.exe is that WT.EXE is not a "true" binary file. It is an alias. It can point to Windows Terminal or to its Preview version. You cannot call an alias from the Registry. This will fail. The context menu doesn't recognize aliases. This is why I used the start command.
Author
Owner

@DHowett commented on GitHub (Oct 25, 2023):

Thanks!

Okay, so, there's a some things to unpack here.

We've not received any reports that Explorer cannot launch app execution aliases directly; that's actually how Win+X->Terminal works (!), and all ShellExecute() (like running wt from the address bar in explorer.)

It might be worth trying pointing to wt directly and seeing how that works out for you. If it's still broken, there might be other things we can do (like launching via shell:appsfolder/....)

@DHowett commented on GitHub (Oct 25, 2023): Thanks! Okay, so, there's a some things to unpack here. We've not received any reports that Explorer cannot launch app execution aliases directly; that's actually how <kbd>Win+X</kbd>->Terminal works (!), and _all_ `ShellExecute()` (like running `wt` from the address bar in explorer.) It might be worth _trying_ pointing to `wt` directly and seeing how that works out for you. If it's still broken, there might be other things we can do (like launching via `shell:appsfolder/....`)
Author
Owner

@DHowett commented on GitHub (Oct 25, 2023):

At the end of the day though, I don't know that this is something we're entirely in control of. I'm gonna close this bug until we've got some more info 😄

@DHowett commented on GitHub (Oct 25, 2023): At the end of the day though, I don't know that this is something we're entirely in control of. I'm gonna close this bug until we've got some more info :smile:
Author
Owner

@lhecker commented on GitHub (Oct 25, 2023):

Specifically, it's shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App. If you put it into quotes, you can run WT from Win+R that way as an alternative to using the alias. Unfortunately, it doesn't work under these registry keys (I've just tested it).
I find it interesting though that wt.exe -d "%1" actually works perfectly fine for me. I can't reproduce any issues that would warrant the use of cmd.exe. (Windows 11, build 25962.)

@lhecker commented on GitHub (Oct 25, 2023): Specifically, it's `shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App`. If you put it into quotes, you can run WT from Win+R that way as an alternative to using the alias. Unfortunately, it doesn't work under these registry keys (I've just tested it). I find it interesting though that `wt.exe -d "%1"` actually works perfectly fine for me. I can't reproduce any issues that would warrant the use of `cmd.exe`. (Windows 11, build 25962.)
Author
Owner

@Stanzilla commented on GitHub (Oct 27, 2023):

Specifically, it's shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App. If you put it into quotes, you can run WT from Win+R that way as an alternative to using the alias. Unfortunately, it doesn't work under these registry keys (I've just tested it). I find it interesting though that wt.exe -d "%1" actually works perfectly fine for me. I can't reproduce any issues that would warrant the use of cmd.exe. (Windows 11, build 25962.)

Even from the registry? As far as I understand it, that's the problem?

@Stanzilla commented on GitHub (Oct 27, 2023): > Specifically, it's `shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App`. If you put it into quotes, you can run WT from Win+R that way as an alternative to using the alias. Unfortunately, it doesn't work under these registry keys (I've just tested it). I find it interesting though that `wt.exe -d "%1"` actually works perfectly fine for me. I can't reproduce any issues that would warrant the use of `cmd.exe`. (Windows 11, build 25962.) Even from the registry? As far as I understand it, that's the problem?
Author
Owner

@lhecker commented on GitHub (Oct 28, 2023):

Yes, exactly. It works fine from the registry for me. If it doesn't work for you, I think it's likely that this was a limitation that has been resolved in an upcoming version of Windows 11 (I mean 25962 is a public version, but it's in the Dev/Canary channel). I haven't tested it on the version that is currently being rolled out ("SV2" / "23H2"), but I hope that whatever got fixed is already in that version.

@lhecker commented on GitHub (Oct 28, 2023): Yes, exactly. It works fine from the registry for me. If it doesn't work for you, I think it's likely that this was a limitation that has been resolved in an upcoming version of Windows 11 (I mean 25962 is a public version, but it's in the Dev/Canary channel). I haven't tested it on the version that is currently being rolled out ("SV2" / "23H2"), but I hope that whatever got fixed is already in that version.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20665