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

syscall, os/exec: Support running child process as different user on Windows #35653

mappu opened this issue Nov 17, 2019 · 2 comments


Copy link

mappu commented Nov 17, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13.4 windows/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?


What did you do?

Try to launch a process as a different user. Found syscall.Credential can be supplied as a SysProcAttr to exec.Cmd.

What did you expect to see?

Ability to launch process as different user, on all supported OSes.

What did you see instead?

syscall.Credential only supports UID/GID and only works on Unix-like systems. There's no option for Windows (based on either CreateProcessWithLogonW call, or LogonUser/CreateProcessAsUserW pair call).

Copy link

acln0 commented Nov 18, 2019

On Windows, syscall.SysProcAttr is this:

I think you can load the appropriate DLL for LogonUser (see, call the function, which grants a syscall.Token, then use it with SysProcAttr.

Copy link

Thanks @acln0, I think you're right.

I believe this is a duplicate of #21105. I think the associated CL, includes an example of this. I'll close this as a duplicate, but please let me know if I am mistaken.

@golang golang locked and limited conversation to collaborators Nov 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

4 participants