OpenConsole.exe vs conhost.exe, questions #12115
-
I stumbled on a thread here where it was pointed out that OpenConsole.exe could replace conhost.exe. While I did not replace conhost.exe, I found that is was easy enough to start a console app in OpenConsole instead of conhost. I've simply used my favorite shell ... "openconsole.exe d:\tc26\tcc.exe". And that gives me many questions. Is there a place where I can read about command line arguments for OpenConsole and/or the differences/similarities between OpenConsole and conhost? I noticed that OpenConsole reads HKCU\Console. Can I get it to read a subkey of HKCU\Console? One noticeable difference is that after setting custom tabstops (usingTBC and HTS), those settings are lost if I "CMD /C" while using conhost.exe (first pic below), and they're not lost if I do the same thing while using OpenConsole (second pic below). What's the difference there. ["CMD /C" is nothing special. There are many ways I can clobber the tab settings in conhost and not in OpenConsole.] Thanks in advance. - Vince Conhost: OpenConsole: |
Beta Was this translation helpful? Give feedback.
Replies: 15 comments 14 replies
-
Fundamentally, they're the same thing. When the code in this repo for We're explicitly not documenting the arguments to conhost, because then 3rd party developers could take a dependency on those arguments, and we would have a lot less flexibility in changing them in the future. Generally, the arguments only exist to help support conpty scenarios. If we really needed to change them in the future, we like keeping the door open for that. The astute reader could go looking through this repo to find the args to conhost if they really wanted, but again, there's no contract here - those are subject to change at any time. As far as the tab stops thing - what version of Windows are you on? We had a change a while ago where turning VT support off and on would reset the tabstops set by VT. And for reasons that I don't want to get into the weeds on, |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response, Mike. As for the tab thing, as I said, cmd.exe is not special. I'm pretty sure it's my shell doing what cmd.exe does ... turn VT processing off/on in various scenarios. I see evidence of it when starting just about anything, including pipe instances. Making the tab settings "static" is a nice touch (and suits me just fine). I found the command line args in the source (nothing very interesting to me). When I "openconsole.exe myshell.exe", it's not same as Windows using conhost.exe. Openconsole.exe becomes the parent of myshell.exe, an apppropriate subkey of HKCU\Console is not read (if it exists), the console does not automatically display myshell's icon, and probably more differences I'm yet to discover. From your remarks I suppose that would change if Windows actually used openconsole.exe. Short of actually replacing conhost.exe with openconsole.exe (I've read several "no guarantees" from you (Mike) and Dustin) is there a way to mimmick running an app in openconsole.exe the same way that Windows runs an app in conhost.exe? |
Beta Was this translation helpful? Give feedback.
-
You asked and I neglected to reply. I'm on Microsoft Windows 10 Pro for Workstations Should I expect conhost.exe to reset the tabstops when VT is toggled? |
Beta Was this translation helpful? Give feedback.
-
So technically, yes, there's a way to do it, but I'm not positive that this counts as supported. So HERE BE DRAGONS. Technically, what happens when the OS determines that you're launching a console application that doesn't currently have a console server, it creates a new You know what, now that I've typed this all up, I'm pretty sure there isn't a way to do this publicly. That private API, the one that re-parents a process, that's probably the one you really want to be able to call. I'm pretty confident that we won't be able to make that one publicly available. Running As far as the tabstops thing - I asked for your version number, but I honestly have no recollection of when that was actually changed. #140 looks like it's about what we're looking for, but then that would have shipped in 1809, so that's not right. Then there was #4669/#5173, which is a good amount more recent. Judging only based off of bot comments, this one hasn't made it to an Insider's build yet, but that can't be right - @DHowett did the bot miss a bunch of commits when we just bulk merged a bunch of stuff to OS> |
Beta Was this translation helpful? Give feedback.
-
The bot that comments on insider build merges is me :) and this was one of the earlier fixes we made, so I almost certainly didn’t have a process for tracking them back then. I believe James fixed tab stops? |
Beta Was this translation helpful? Give feedback.
-
Thanks again. Sometime fairly recently I read about a re-parenting hack but that's not sufficiently important to make me look for it again. I was more interested in the convenience of getting OpenConsole automatically. Do you want reports of differences between OpenConsole and Conhost ... even when Conhost seems to have the edge? Two are pretty obvious.
|
Beta Was this translation helpful? Give feedback.
-
I would go so far as to say: no, we do not want such reports. They are built out of the same code (delta a couple private APIs). OpenConsole is not a shipping production scenario and we will not be changing it to address any perceived differences from conhost. |
Beta Was this translation helpful? Give feedback.
-
(The icon/registry key/shortcut detection is broken because OpenConsole isn’t receiving the LPSTARTUPINFO that the erstwhile parent process started with... because it isn’t being spawned in response to somebody else needing a console handle.) |
Beta Was this translation helpful? Give feedback.
-
If you want to get OpenConsole automatically, replace conhost on your system. No warranty is expressed or implied. Right now, it’s the only way. Eventually, the spec in #7414 will land and we’ll agree on how to seamlessly replace conhost with some other console host. |
Beta Was this translation helpful? Give feedback.
-
The conhost.exe process is the child of the allocating process. That has been the case since the ConDrv device was introduced in Windows 8. IIRC, in the old Windows 7 implementation that used ALPC pseudo-files instead of a device, each conhost.exe session was created by the desktop session server, csrss.exe. From what I remember from the last time I walked through this in a debugger, the console init routine in kernelbase does basically the following steps:
|
Beta Was this translation helpful? Give feedback.
-
I replaced conhost (briefly). It worked OK but I didn't like looking at the white scroll bar. |
Beta Was this translation helpful? Give feedback.
-
Ah, console users can be so picky. 😄 |
Beta Was this translation helpful? Give feedback.
-
We have been spoiled. |
Beta Was this translation helpful? Give feedback.
-
@DHowett sorry to resurrect an answered thread but I had a small question. In the old console, we could do something like the following to change the console icon from inside an external TUI program.
(The example ^ is from vim codebase.) It doesn't seem to change the icon in the Windows Terminal tabs. Is there a similar API which handles such cases? I read the thread. Can't say I followed much. Apologies if it's already been answered. I realize this repo is absolutely brimming with people engaging, asking, wanting. Must be exhausting. |
Beta Was this translation helpful? Give feedback.
-
Somewhat along these lines ... My preferred shell, TCC, used the position and size of the ConsoleWindowClass window to locate and size various things (options diablog, pop-up command and directory history, MSGBOX command). Things are less than optimal when it's using the position and size of the PseudoConsoleWindow window. I can move/resize the PseudoConsoleWindow class window to match the CASCADIA_HOSTING_WINDOW_CLASS window (is that OK?). And that makes things better. But there's another problem ... Using some of TCC's GUI features cause the PseudoConsoleWindow class window to be shown (it's not very interesting). Can that window be made to keep itself from being shown? And, a little to my surprise, the PseudoConsoleWindow class window has WS_VISIBLE by default (so says Spy++). ... ????? |
Beta Was this translation helpful? Give feedback.
Fundamentally, they're the same thing. When the code in this repo for
openconsole.exe
is built by the Windows build system, it turns intoconhost.exe
. Really, the only difference you're gonna see between the two is that the OpenConsole in this repo (and that ships with the Terminal) has a few more months of bug fixes and features added to it relative to theconhost.exe
in yoursystem32
. If someone's interested, I could give a history lesson on why the two are named differently, but that's more of an aside.We're explicitly not documenting the arguments to conhost, because then 3rd party developers could take a dependency on those arguments, and we would have a lot less flexibility in chan…