Process.Start() impersonation problem

DxCK picture DxCK · Oct 14, 2010 · Viewed 13.8k times · Source

Trying to start process with another access token, without success, it runs as the non-impersonated user.

using (WindowsIdentity identity = new WindowsIdentity(token))
using (identity.Impersonate())
{
    Process.Start("blabla.txt");
}

How to make this work properly?

Answer

Hans Passant picture Hans Passant · Oct 14, 2010

You need to set the ProcessStartInfo.UserName and Password properties. With UseShellExecute set to false. If you only have a token then pinvoke CreateProcessAsUser().