wslg
wslg copied to clipboard
Windows 11 Ubuntu 20.0.4 LTS MSTSC constant launch
Version
Version 10.0.22000.376
WSL Version
- [X] WSL 2
- [ ] WSL 1
Kernel Version
5.10.60.1
Distro Version
Ubuntu 20.04 LTS
Other Software
Windows Remote Desktop (v10.0.22000.282)
Repro Steps
Install ubuntu 20.04 LTS on Windows 11 after enabling WSL and then configure for WSL version 2 Then open Ubuntu 20.04, log in, and wait a moment or 2. Open process explorer (from PSTools) You'll see that mstsc.exe is constantly loading
Expected Behavior
With WSLg enabled, it should just launch mstsc.exe ONCE not constantly
Actual Behavior
MSTSC.exe keeps launching over and over and over again, and constantly stealing focus from other apps on Windows 11.
Diagnostic Logs
Example launch command that it is calling over and over again:
mstsc.exe /v:FD5381AC-7B10-4819-BD14-202E7C76F7B1 /silent /hvsocketserviceid:34D15B6B-FACB-11E6-BD58-64006A7986D3 /wslg /plugin:WSLDVC /wslgsharedmemorypath:WSL\FD5381AC-7B10-4819-BD14-202E7C76F7B1\wslg C:\ProgramData\Microsoft\WSL\wslg.rdp
You can work around this issue, by doing the following:
Open Powershell, and run wsl --shutdown
Open File Explorer on Windows 11:
- Go to your local profile
- Creating a .wslconfig file (or edit the one that is there)
- Adding the following text:
[wsl2]
guiapplications=false
Open ubuntu. Now, WSLG is disabled, and MSTSC stops coming up over and over again.
Hello. I just want to mention that I have the same issue. It is annoying because, at some point, it keeps on launching it and I cannot even use my terminal anymore (except if clicking like mad to steal focus away from mstsc.exe at each keystroke). Furthermore, there's nothing I can do to stop it when it occurs.
The strange thing is that it starts whenever I open Photoshop. Maybe Photoshop somehow wrecks havoc on the GPU, which leads to the X server being unable to work?
Interestingly, knowing it was somehow related to WSLg, I tried to launch xterm in my WSL2 terminal : I managed to do it, but it said :
xterm: Xt error: Can't open display: :0
There's a fix, though : open RD client on my iPhone, connect to my PC, then disconnect.
Once I manage to use the PC again, I notice that xterm & now works.
It's not a complete fix because, mstsc keeps on stealing focus from time to time (after the "fix" rdp session)
Some days it does not happen at all and some others it's just a couple of times a day. But when it happens once, it tends to do it more over the next hour, unless I reboot.
Once I open Photoshop and copy part of an image to the clipboard, though, it starts like crazy. Sometimes it stops all on its own. BTW I am not complaining ! I love WSLg and it's preview software yet... But I wanted to tell my story so that maybe it'll give you some clues.
(apologies... I am French speaking)
You can work around this issue, by doing the following:
Open Powershell, and run
wsl --shutdownOpen File Explorer on Windows 11:
- Go to your local profile
- Creating a .wslconfig file (or edit the one that is there)
- Adding the following text:
[wsl2] guiapplications=falseOpen ubuntu. Now, WSLG is disabled, and MSTSC stops coming up over and over again.
Thanks for the workaround. I can confirm this is still happening on 22000.675, two or three times a day at this point. For those having trouble running wsl --shutdown in a terminal I recommend creating a shortcut to execute this and placing it on the desktop or somewhere else you can access with mouse-only navigation (since typing is nearly impossible when the issue is happening).
Just confirming that I was having the same issue. I have enabled the flag "guiapplications=false" for now but would like to see it fixed. I first noticed the issue when I upgraded to Windows 11 22H2 build 22621.105
I experience the same issue, but it is mostly when I keep Jupyterlab open (not via wslg, though - in the Windows version of Edge). After some time, it keeps stealing focus and makes it very difficult to work.
Hi. I've had this problem a few times recenty. I've noticed this happens for me when I take a screengrab in Greenshot and copy it to the clipboard. If I put something else in my clipboard, it stops happening.
Looking at Greenshot's Expert settings, it puts DIB and PNG formats into the Clipboard.
I did a bit of informal testing, and I think unchecking the DIB format worked around the issue, although this seems to limit where the image may be pasted.
@countingpine yep, same repro for me with Greenshot.
@countingpine try unstable version and check if problem persists 👍
Just to say, I can no longer reproduce the issue on my computer. Perhaps a WSL[g] update has fixed the problem.
I'm now on Microsoft Windows [Version 10.0.22000.856]. My Greenshot version is 1.2.10 Build 6 (64 bit).
If the problem ever recurs, I'll post back with more info, but I think as far as I'm concerned the problem seems to be fixed.
@programcsharp is it still a problem for you?
I had the issue several times and could not pinpoint the cause. I don't use Greenshot, but I do use Picpick instead. If this can somehow be caused by having a bitmap in the clipboard, I should have it happen again at some point.
I'm still monitoring to verify the clipboard workaround.
It's happened again today. Same Windows/Greenshot version as I posted above.
I've installed the unstable Greenshot (1.3.270 - 511034a34b), without restarting. The problem seems to have gone away.
I'll come back if it re-recurs.
I've had it happen a few more times as well. No meaningful log, no clear culprit. I don't have greenshot and couldn't trace the issue starting to anything in particular that I had done in the minutes before.
The other times, I managed to logout or reboot, and the issue stopped. This last time, I ran the "wsl" command on powershell, and the issue stopped as soon as I was dropped into bash.
It's really hard to do anything while the issue is in ocurring, because every launch of the MSTSC steals focus.
Same story here, WSL rdp every 30 seconds was stealing the focus, additionally in an EventViewer, I can see that:
RDPClient_TCP: "TcpEventConnectionTimeout" (Error code: 0x80004004)
happens also every 30 seconds.
The trick with .wslconfig worked to stop this behavior.
You can work around this issue, by doing the following:
Open Powershell, and run
wsl --shutdownOpen File Explorer on Windows 11:
- Go to your local profile
- Creating a .wslconfig file (or edit the one that is there)
- Adding the following text:
[wsl2] guiapplications=falseOpen ubuntu. Now, WSLG is disabled, and MSTSC stops coming up over and over again.
Same issue but I use WSA rather than WSLG ,wondering if it can be solved like this ?
Same issue for me, I lose focus randomly to mstsc.exe from C:\ProgramData\Microsoft\WSL\wslg.rdp, currently on Windows 11 22H2 22621.674 Windows Feature Experience Pack 1000.22634.1000.0. I've never been a Windows Insider member to avoid bugs, so this is more general.
The problem appeared with the installation of Windows 11 22H2.
I solved the problem but with a solution a bit extreme.
The problem came from the wsl kali-linux distribution, an uninstall from windows and coupled with a wsl --unregister fixed the problem.
For me, it didn't seem to come from Ubuntu, that would have been more annoying...
For me, it's caused by having the Overwolf app running, strangely enough. Every 30-60 seconds I lose focus.
Overwolf is such a garbage frontend, that doesn't surprise me one bit lol
This is also happening to me and I believe it started after update 22H2. I kept losing focus of the window I was using every couple of minutes. Using a focus logger I was able to pin it down to mstsc.exe. Disabling wslg seems to have resolved the issue which is unfortunate because I would like to use it for gui apps.
This issue with WSLg poking mstsc.exe to steal focus is just killing my productivity as well. Literally while I'm trying to type this bug report it's stolen my focus twice (update: 3 times). Just how is this still a problem almost a year later? Lately, I've had reasons to make use of the GUI layer so I'd rather not just disable it completely.
The current workaround for me that suits me well is to disable wslg (see https://github.com/microsoft/wslg/discussions/523) and use gwsl instead (https://apps.microsoft.com/store/detail/gwsl/9NL6KD1H33V3?hl=fr-be&gl=be) . Any other X server will do, but I find gwsl easy to use.
I had the same issue and found on this article the reason why :
- My system is running with an Asus Motherboard and I installed Asus tools with it.
- One of them is called Armoury Crate and has a background running process (ArmouryCrate.UserSessionHelper.exe) that scans a lot of paths (including network drives) and more specifically \wsl.localhost\kali-linux\
- Every time I ran
wsl --shutdownmy Kali Linux restarted a few seconds later and the related mstsc.exe as well. - Having mstsc.exe running permanently in the background generated my main issue losing focus between windows.
- Removing Armoury Crate solved my issue.
Disabling WSL guiApplications fixed the issue for me.
I initially thought I was touching the trackpad by mistake and took me a while to figure out it wasn't me.
Can still confirm this issue. Haven't yet found out, what it is.
Fired up process explorer and searched for handles with Ctrl+Shift+F with "WSL" in it:
In my Explorer I had the Linux location expanded, maybe it was accessing the wsl resources. Visual Studio is also having some WslDebugging extensions loaded (my visual studio project does not actively use WSL)
It also happens periodically on my machine. I roughly correlate it with the time I installed Multipass and MicroK8s, albeit Multipass is currently not running, when this focus issue occurs.
Edit: Seems to be explorer (sometimes)
When I expanded the linux location again, the focus issue started immediately:
Almost 3 years since this issue was opened and I found myself with the same extremely annoying problem. Come on, Microsoft, that's a ridiculous bug!
Can confirm that happens when a certain type of image is in your clipboard (for me it was a copied image from skype)
[wsl2] guiapplications=false
Is not a solution. I want to continue using WSLg which worked flawlessly, it just suddenly started MSTSC following an update for me. I don't get it, where is this even executed and why ? There has to be some setting for this. the previous version worked flawlessly and launched WSLg with no issues, this MSTSC thing is a new feature/bug.
Oddly i am on Win10 (not 11). And this only appeared recently (in 2025) maybe after a Windows preview Update ; oddly this bug is open since 2022 ???
Maybe this seems to be a better approach : https://github.com/microsoft/wslg/issues/901
[system-distro-env]
WSLG_USE_MSTSC=false