4

I've noticed whenever I launch a VS Code WSL session I get an mstsc.exe (Remote Desktop Client) process running. I don't think this is a problem in itself however mstsc is causing some flickering and poor overall system performance even though CPU and memory usage isn't excessive.

How is mstsc.exe related to VS Code Remote WSL? Is it needed if I'm not running any graphical desktop applications in WSL? Can th remote session run without mstsc?

I had never noticed this prior to upgrading to Windows 11 in case that's significant.

Mark
  • 41
  • 2
  • That's very weird (it's also very weird that simply having `mstsc.exe` open causes flickering, that makes no sense at all). My suggestion is to use a tool like [ProcExp](https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer) which can show you the process-tree which will help identify why or how arbitrary commands can start unrelated processes. Also use `ProcMon` (also in SysinternalsSuite) to see what's going on. – Dai Feb 01 '22 at 07:00
  • actually the flickering and poor performance don't happen all the time but the are definitely related to mstsc.exe. I just had a look and pocess explorer and it shows that mstsc.exe is actually a child of service -> svhost.exe -> wslhost.exe but the process defeintely starts and stops with VSCode remote sessions. If i use WSL without VS Code it doesn't run. – Mark Feb 01 '22 at 07:14
  • In that case, use ProcMon (and [ProcMon-for-WSL](https://github.com/Sysinternals/ProcMon-for-Linux/)) to find out what inside WSL is starting mstsc. – Dai Feb 01 '22 at 07:20
  • 1
    Thanks. This led me down the right track. looks like something to do with WSLg. More info here: https://devblogs.microsoft.com/commandline/wslg-architecture/ Disabling this has solved the problem for now. – Mark Feb 01 '22 at 10:06
  • Ah, that's the explanation then - WSLg uses RDP and `mstsc.exe` to expose the X11 environment (I'd have preferred it if it interfaced directly with the DWM, but oh well). – Dai Feb 01 '22 at 10:20

2 Answers2

1

I use this app https://superuser.com/a/1042066/3489 to identify mstsc.exe as the cause of desktop / input focus flickering.

Event Viewer > Windows Logs > Security > Microsoft Windows security auditing confirmed it was mstsc.exe being launched by Creator Process Name: C:\Windows\System32\lxss\wslhost.exe

And finally wsl --shutdown made it stop.

Todd Smith
  • 17,084
  • 11
  • 59
  • 78
0

If don't want to disable WSLg you could try the solution of this similar problem: https://github.com/microsoft/wslg/issues/676. For me, updating wsl from aka.ms/wslstorepage seems to have solved the flickering problem.

jpw
  • 1