Skip to content

Add winpty support for Windows agents#297

Open
MartinMa wants to merge 1 commit intoYlianst:masterfrom
MartinMa:feature/winpty_2025
Open

Add winpty support for Windows agents#297
MartinMa wants to merge 1 commit intoYlianst:masterfrom
MartinMa:feature/winpty_2025

Conversation

@MartinMa
Copy link

@MartinMa MartinMa commented Sep 2, 2025

This pull request adds winpty support to MeshAgent and is open for discussion.

Closes Ylianst/MeshCentral#4327

winpty provides functionality similar to Windows Pseudo Console (ConPTY), when ConPTY is not available.
See https://github.com/rprichard/winpty

In order for it to work, winpty.dll and winpty-agent.exe are installed alongside the agent binary. I included pre-built versions these two files as Visual Studio resources that are compiled into the meshagent binary, which are installed during MeshServer_ConnectEx using deployWinPtyDependencies (see modules/service-manager.js). The files are taken from the Microsoft VSCode release bundle, because it ships with these files too.

The most important changes are in modules/service-manager.js (installation of winpty deps) and modules/win-terminal.js (agent plugin replacement).

Some thoughts: Due to the fact, that the winpty dependencies are compiled into the agent binary, the overall file size of MeshService64.exe increases. Another idea would be to make a "legacy Windows MeshAgent" binary with winpty support and a smaller one without (that uses ConPTY). Another idea would be that MeshCentral sends these dependencies over the network after installation if needed to keep the file size small.

Note: We successfully tested this solution on Windows 10, version 1607 (64-bit). It should work on 32-bit Windows systems as well. I included the 32-bit binaries of winpty. But that still needs testing!

@si458
Copy link
Collaborator

si458 commented Sep 4, 2025

i will have to ask @Ylianst to have a look at is for me,
as putting a dll and exe next to the binary would now mean the app is no longer portable
AND it means we would have to create an installer which is another ball ake!?

@MartinMa
Copy link
Author

MartinMa commented Sep 4, 2025

Ok thanks!

For clarification: The dll (and winpty-agent.exe) would only be compiled into the binary for agents with compile target "Windows". There are compiler switches for that (see #ifdef WIN32).

The installation routine in service-manager.js would copy the dll from the binary using the win32 api FindResourceW and the like. So the agent is its own setup.

But I'm also not exactly happy with the design to have the dll and winpty-agent.exe as binary resource. So ideas are welcome.

@si458
Copy link
Collaborator

si458 commented Sep 4, 2025

@MartinMa oh right ok! got you!
so the dll/exe would indeed be built into the exe, and when you run the exe it would extract it!
thats perfectly fine! as we currently do that for the .msh!
it adds the .msh info into the exe when you download from the web ui,
then on run it extracts it and put into its own .msh file!

side note:
would also be good to change the .msh method too so it to is a resource file
then it allows for the windows signature bug to be fixed also! (but thats a different problem!)

@PacGyver
Copy link

Is it possible to integrate this? I have a few Windows Server 2016 systems and can't really use PowerShell on them.

@si458
Copy link
Collaborator

si458 commented Jan 22, 2026

@PacGyver it requires a lot of testing first and would require yet another meshagent update
But we can look into it this year

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terminal (cmd or powershell) only work for a few seconds - latest 1.0.60 release

3 participants