0

When creating a new process with the following code, an exception is raised that the operation requires elevation. Is there a way to allow Process.Start to use a different user's credentials to start the process even if the current user is not an administrator?

        private Process CreateProcess(string path, string username, SecureString password, string domain)
        {
            Process proc = new Process();
            proc.StartInfo.FileName = path;
            proc.StartInfo.UserName = username;
            proc.StartInfo.Password = password;
            proc.StartInfo.Domain = domain;
            proc.StartInfo.LoadUserProfile = true;
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.ErrorDialog = true;
            return proc;
        }
  • https://learn.microsoft.com/en-us/dotnet/api/system.security.principal.windowsidentity.impersonate?view=netframework-4.8. You can also configure the application to require admin to run it (they'll get the standard UAC prompt if needed). https://stackoverflow.com/questions/2818179/how-do-i-force-my-net-application-to-run-as-administrator – itsme86 May 20 '20 at 21:42
  • So is your idea here to impersonate the administrator user, and using that context launch the program? – Jacob Willinger May 20 '20 at 21:51
  • 1
    That would be one way to do it. – itsme86 May 20 '20 at 22:05
  • Please explain what is "an exception is raised that the operation requires elevation". Even a screen shot can reveal enough on what you saw, so don't ask others to guess. – Lex Li May 21 '20 at 01:53

0 Answers0