Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL cannot be executed from a windows service using local admin account #9451

Closed
1 of 2 tasks
s3menzer opened this issue Jan 6, 2023 · 6 comments
Closed
1 of 2 tasks

Comments

@s3menzer
Copy link

s3menzer commented Jan 6, 2023

Version

Windows Version: 10.0.19044.2364

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.79.1

Distro Version

Ubuntu 22.04

Other Software

WSL-Version: 1.0.3.0
Kernelversion: 5.15.79.1
WSLg-Version: 1.0.47
MSRDC-Version: 1.2.3575
Direct3D-Version: 1.606.4
DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows Version: 10.0.19044.2364

Repro Steps

Setup a windows service that executes wsl.exe to run linux commands (in our case it a bamboo build agent)

Expected Behavior

WSL version is printed out

Actual Behavior

%ERRORLEVEL% is set to 1 and with the follwing output:

Das System kann auf die Datei nicht zugreifen.

Diagnostic Logs

The behavior exists after wsl was updated to the current release

If I run wsl -l -v with the same user on a windows terminal, I get the following output instead:

WSL-Version: 1.0.3.0
Kernelversion: 5.15.79.1
WSLg-Version: 1.0.47
MSRDC-Version: 1.2.3575
Direct3D-Version: 1.606.4
DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows Version: 10.0.19044.2364

@s3menzer
Copy link
Author

s3menzer commented Jan 9, 2023

It is working as long as the local user account which is used by the service to authenticated is not part of the group of local admins

@aki-k
Copy link

aki-k commented Jan 9, 2023

I thought this was the same case as trying to run wsl from task scheduler

#9231

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 17, 2023

/dupe #9231

@ghost
Copy link

ghost commented Jan 17, 2023

Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread.

Thanks for your report!

@ghost ghost closed this as completed Jan 17, 2023
@ghost ghost added the duplicate label Jan 17, 2023
@s3menzer
Copy link
Author

Found a solution now:

In some cases, wsl (LxssManager service may hang while shutting down. Therefore the service
must be started in unprotected mode.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LxssManager]
"LaunchProtected"=dword:00000000

With this setting set, the service can be killed by the following command:

taskkill /F /FI "SERVICES eq LxssManager"

If you kill it before starting "wsl.exe", everything will be fine

@aki-k
Copy link

aki-k commented Jan 27, 2023

@s3menzer

It is working as long as the local user account which is used by the service to authenticated is not part of the group of local admins

Thank you very much. This resolved my issue of starting WSL as a Windows service at boot.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants