Elevating process privilege programmatically?

前端 未结 5 928
情歌与酒
情歌与酒 2020-11-22 00:05

I\'m trying to install a service using InstallUtil.exe but invoked through Process.Start. Here\'s the code:

ProcessStartInfo startInfo = new Pro         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 00:27

    You should use Impersonation to elevate the state.

    WindowsIdentity identity = new WindowsIdentity(accessToken);
    WindowsImpersonationContext context = identity.Impersonate();
    

    Don't forget to undo the impersonated context when you are done.

提交回复
热议问题