terminal: Context Menu -> Open in Windows Terminal -> "The server threw an exception"

Note:

  1. Right Clicking on a folder and then opening the terminal works.
  2. Going inside the folder, then right clicking on empty space, and then opening the terminal gives error.
  3. I believe this was a known issue with older windows versions, that is why it was disabled earlier, but i think i saw a PR that implemented the functionality differently for older windows, but it is still not working for me
  4. I restarted explorer.exe, still gives the error. Maybe restarting the computer will make it work? I will try later and update the issue if it works. EDIT: Nope, still not fixed.

image

image

Environment

Windows build number: Microsoft Windows [Version 10.0.18363.1256]
Windows Terminal version: Windows Terminal Preview v1.6.10272.0

Any other software?: Not applicable

Steps to reproduce

Context Menu -> Open in Windows Terminal -> “The server threw an exception”

Expected behavior

It should work

Actual behavior

It doesn’t

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 47
  • Comments: 34 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Right now, we’ve committed the fix to main. We’re working on a couple other hot bugs right now, and should have a servicing release out later this week. Thanks for the patience!

Same issue for me, still not working 😟

This is due to be released in a bugfix update to 1.6 this week.

THANK YOU VERY MUCH

that would be good enough for now I am making a pr to the mess I left

If it’s not too much trouble, we might be able to figure this out by building from source and throwing breakpoints at the top of OpenTerminalHere::_GetPathFromExplorer, in ...src\cascadia\ShellExtension\OpenTerminalHere.cpp. Since this only repros when right clicking in the empty space in explorer, then I’m pretty sure it’s due to the code in that function.

/cc @hereafter, because they might have some ideas what’s going on here (#8638)

Well then this should probably be serviced to 1.5 too. That’s what we get for sneaking features into the stable builds.

Maybe a point worth noting - When I use context menu as the OP has shared, it gives me an error but if I right-click on the folder itself and choose Open in Windows Terminal, it does work.

image

image

hi @zadjii-msft! just wanted to check in to see if this fix was released? I see that the issue is assigned to the v1.7 milestone- should I check back on February 28th?

Thanks, it works perfectly.

diff --git a/src/cascadia/ShellExtension/OpenTerminalHere.cpp b/src/cascadia/ShellExtension/OpenTerminalHere.cpp
index bd748338..1c2649df 100644
--- a/src/cascadia/ShellExtension/OpenTerminalHere.cpp
+++ b/src/cascadia/ShellExtension/OpenTerminalHere.cpp
@@ -266,7 +266,7 @@ std::wstring OpenTerminalHere::_GetPathFromExplorer() const
         return path;
     }
 
-    auto shell = create_instance<IShellWindows>(CLSID_ShellWindows);
+    auto shell = create_instance<IShellWindows>(CLSID_ShellWindows, CLSCTX_ALL);
     if (shell == nullptr)
     {
         return path;
@@ -285,6 +285,7 @@ std::wstring OpenTerminalHere::_GetPathFromExplorer() const
         com_ptr<IWebBrowserApp> tmp;
         if (FAILED(disp->QueryInterface(tmp.put())))
         {
+            disp = nullptr;
             continue;
         }
 
@@ -293,8 +294,10 @@ std::wstring OpenTerminalHere::_GetPathFromExplorer() const
         if (hwnd == tmpHWND)
         {
             browser = tmp;
+            disp = nullptr;
             break; //found
         }
+        disp = nullptr;
     }
 
     if (browser != nullptr)

I have also set up teamviewer, so in case any debugging is still required, please let me know.