Launch a process under another user's credentials

后端 未结 3 1101
一向
一向 2020-11-29 09:39

I want to launch a process under another username\'s credentials. This is what I have now:

        /// 
        /// Do actions under another          


        
3条回答
  •  悲&欢浪女
    2020-11-29 10:12

    I don't think you need to login the user and duplicate the handle. All you need to do is set the username, domain, and password in the ProcessStartInfo object. That's been available since .NET 3.0 if I recall correctly.

    EDIT:

    Also for more information, this is what really happens when you give username/domain/password to ProcessStartInfo: http://support.microsoft.com/kb/165194. The reason for access denied is probably that you don't have access to the user's desktop or windowstation. Just calling LoginUser is not sufficient.

提交回复
热议问题