Calling CreateProcessAsUser from C#

后端 未结 3 887
暗喜
暗喜 2020-12-08 09:11

I\'ve been attempting to create a new process under the context of a specific user using the CreateProcessAsUser function of the Windows API, but seem to be run

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 09:44

    From here:

    Typically, the process that calls the CreateProcessAsUser function must have the SE_ASSIGNPRIMARYTOKEN_NAME and SE_INCREASE_QUOTA_NAME privileges. If this function fails with ERROR_PRIVILEGE_NOT_HELD (1314), use the CreateProcessWithLogonW function instead. CreateProcessWithLogonW requires no special privileges, but the specified user account must be allowed to log on interactively. Generally, it is best to use CreateProcessWithLogonW to create a process with alternate credentials.

    See this blog post How to call CreateProcessWithLogonW & CreateProcessAsUser in .NET

提交回复
热议问题