How can I create a new process with another User Account on Windows?

后端 未结 5 1317
盖世英雄少女心
盖世英雄少女心 2021-01-11 16:11

Is it possible to create a new process on windows with a different user account? I know there are a context menu \"Run as\" but I want do it from Java. I have the username a

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-11 16:31

    Depending on your needs the Win32 API "CreateProcessWithLogonW" is easier to use than the "CreateProcessAsUser / LogonUser" functions.

    From MSDN Docs:

    The CreateProcessWithLogonW and CreateProcessWithTokenW functions are
    similar to the CreateProcessAsUser function, except that the caller 
    does not need to call the LogonUser function to authenticate the user 
    and get a token
    

提交回复
热议问题