Search code examples
c#.netimpersonationrunasroaming-profile

C#: Load roaming profile and execute program as user


In an application I need to execute other programs with another user's credentials. Currently I use System.Diagnostics.Process.Start to execute the program:

public static Process Start(
   string fileName,
   string arguments,
   string userName,
   SecureString password,
   string domain
)

However this function does not load the roaming profile from the net - which is required.

I could use "runas /profile ..." to load the profile and execute the command, but that would ask for a password. There must be an more elegant way...

But where?


Solution

  • System.Diagnostics.ProcessStartInfo.LoadUserProfile