2

I want to manage a service running inside WSL via a wrapper service running on Windows. But when I try to run the wrapper Windows service (which by default run as the "System" user, it throws an "Access Denied" error.

Same service when run as a normal Admin user works fine.

Does anyone know of a way to work around this and make it possible to run bash.exe as the "System" user? Or is that way by design and should be avoided?

Note: I use the following go code to run the WSL service. (I build this command into an exe and install it on Windows as a service using winsw)

exec.Command("bash.exe", "-c", "sudo /bin/bash service my-linux-service start")

1 Answer 1

2

Ran into the same issue today,
I'm using NSSM to setup Windows services and I manage to sort things out by setting the objectName to the current user for this service.
Now my service is executed by a user that can access WSL :

nssm set <servicename> ObjectName <username> <password>

Note: <username> should exactly be the output of whoami.exe

See NSSM Documentation for more info.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.