Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Open a TCMD Tab with a Conhost TCC Session

Jun
1,092
48
I can run the following command from a TCC tab:

Code:
start /pgm C:\Windows\System32\conhost.exe C:\PROGRA~1\JPSoft\TCMD36\tcc.exe

A standalone session starts, which I can then attach to TCMD (albeit with the initial command-line input problem I reported earlier). So then I try the following command to accomplish both tasks at once:

Code:
start /tab /pgm C:\Windows\System32\conhost.exe %tcmdpgmdir\tcc.exe

When I do that, the system hangs for a while and eventually displays a new prompt. No new tab opens, and no new window opens. However, the TASKLIST command shows that there is a new TCC task running; it just isn't visible anywhere. If I open the tab attachment window, I see the task, and I can attach it.

Is this some kind of timing issue? Is it related perhaps to the problem with the initial command-line entry upon attachment?

When I run the following command to open a ConPTY session in a new tab, it works. The new tab opens.

Code:
start /tab /pgm C:\PROGRA~1\JPSoft\TCMD36\tcc.exe

But one thing is different: the ansi sequences in my prompt (which underline some of the prompt to show that it is a ConPTY session) are not working. The variable %_conpty is 1. Oh, the other ConPTY things are also not working in that tab. The gutters on the left and right are like those for a conhost session. So it seems to be some kind of hybrid. The variable %_conpty says it is a ConPTY session, but everything else says it's not.
 
Conhost.exe is a GUI app. It doesn't make much sense to run it in a tab. Start /tab /pgm notepad behaves similarly.
 
When I run the following command to open a ConPTY session in a new tab, it works. The new tab opens.

start /tab /pgm C:\PROGRA~1\JPSoft\TCMD36\tcc.exe
But one thing is different: the ansi sequences in my prompt (which underline some of the prompt to show that it is a ConPTY session) are not working. The variable %_conpty is 1. Oh, the other ConPTY things are also not working in that tab. The gutters on the left and right are like those for a conhost session. So it seems to be some kind of hybrid. The variable %_conpty says it is a ConPTY session, but everything else says it's not.

After doing that is your original tab healthy? See my new thread about underlining.
 
Yes, the original tab is still working as before.

Rex, I'm really puzzled by these tab sessions that report that they are ConPTY but seem to be legacy console sessions. The gutters do not have the command-folding marks or the success-failure marks, and the extended ansi sequences, such as for underlining, do not work.
 
If your console session does not have ANSI enabled, you won't get folding, prompt ticks, or any of the extended ANSI sequences.

TCC sends the shell integration ANSI sequence when it starts, not at some random later time after it's been attached to a TCMD tab. So if you want those things, you'll need to send the sequence yourself.
 
I realized belatedly what you are trying to do -- which you cannot do.

It is not possible to attach a ConPTY session to TCMD, because there is no way for TCMD to get the pipe handles to the ConPTY process. So you're going to have a non-ConPTY conhost session here, and shell integration & extended ANSI sequences aren't going to work.
 
Rex, somewhere I saw that you asked if the variable _conpty was the one in TCC or one from a plugin. I removed all plugins, and I still have those sessions where %_conpty is 1 but nothing else looks like the other ConPTY tabs. So, when I run the following command, I end up with a tab in which the value of the variable is still 1, but none of the other things are working like a ConPTY session. The text looks like that in a conhost session (including no artifacts), and the extended ANSI sequences are ignored.

Code:
start /tab /pgm "C:\Program Files\JPSoft\TCMD36\TCC.EXE"

Anyway, thanks for the explanation. I have now created profiles, and they do what I was trying to achieve both when loaded from the Profiles menu and when launched by the command start /profile=profile_name from a TCC tab. I can now open a new tab in ConPTY mode, Legacy (conhost) mode, or Elevated.
 
Yes, there is something REALLY weird:

I have a profile in TCMD for a conhost tab and it's clearly a conhost tab. But %_conpty = 1 ...

PS: tested with build 71

PPS: I made a new thread about the %_conhost var, see here:
 
Last edited:
Rex, somewhere I saw that you asked if the variable _conpty was the one in TCC or one from a plugin. I removed all plugins, and I still have those sessions where %_conpty is 1 but nothing else looks like the other ConPTY tabs. So, when I run the following command, I end up with a tab in which the value of the variable is still 1, but none of the other things are working like a ConPTY session. The text looks like that in a conhost session (including no artifacts), and the extended ANSI sequences are ignored.

Code:
start /tab /pgm "C:\Program Files\JPSoft\TCMD36\TCC.EXE"

Not reproducible here - running that command creates a tab in a non-ConPTY session (%_conpty == 0).

The %_conpty variable IMO is a throw-away that was only added for debugging purposes. Do you have a real need / use for it?
 
Not reproducible here - running that command creates a tab in a non-ConPTY session (%_conpty == 0).
Apparently not so. After start /tab /pgm "d:\tc36\tcc.exe", in the new tab,

Code:
v:\> echo %_conpty
1

But in the same (new) tab,

Code:
v:\> echo %@winapi[user32,GetClassName,%@winapi[kernel32,GetConsoleWindow],buffer,32]
ConsoleWindowClass
 
I can reproduce it too. start /tab %_cmdspec starts a new tab, where:

Code:
C:\>echo %_conpty
1

C:\>echo %_contype
Console

C:\>window info

    Title:  “Admin: TC 36.50 - TCC Prompt - window info”
    Class:  “XTPMainFrame”
    Window handle:  0x00130822    Type:  Take Command
    Window position:  (2013, 454)   Size:  1427 × 938   Monitor:  2
    Virtual desktop:  “Desktop 1”
    State:  Normal    Topmost:  No
    Style:  0x16CF8000    ExStyle:  0x00000100    Visible:  Yes
    Process ID:  0x00001828   Thread ID:  0x00003160
    Filename:  “C:\Bin\TCmd36\TCMD.exe”
    Version:  36.50.71.0
    Tab type:  Console

    Parent window handle:  0x0001000C
    Parent window class :  “#32769”  (the Desktop window)
    Parent window position:  (0, 0)   Size:  3440 × 1440   Monitor:  2
    Parent process ID:  0x000004F8   Thread ID:  0x00000554
    Parent filename:  “C:\Windows\System32\csrss.exe”

C:\>

_CONPTY is the internal variable; _CONTYPE and WINDOW INFO are both from a plugin.
 
Back
Top