0

Here is the scenario: A .NET application is running as a user with non-adminstrator privileges. The application wants to start another process on the computer. The new process must run with administrator privileges. The administrator user name and password is known to the .NET application.

Is this possible to do on a Windows 10 computer. I was trying to use the code below without success.

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = false;
startInfo.FileName = fullPathToExecutable;
startInfo.Arguments = "";

startInfo.Domain = Environment.MachineName;
startInfo.Verb = "runas";
startInfo.UserName = "admin";
SecureString pass = new SecureString();
startInfo.Password = pass;

Process p = Process.Start(startInfo);
Helan
  • 135
  • 2
  • 3
  • 10
  • Not really sure if this is a duplicate, but okay, deep down in the comments of the linked question the same problem is discussed. – Helan Sep 13 '17 at 07:18
  • Found a solution. Start an intermediate process running with startInfo.UserName and startInfo.Password properties set. Then from the intermediate process start another process without username and password, but with startInfo.Verb = "runas". Then the second process will run as the specified user with admin privileges. – Helan Sep 13 '17 at 12:52

0 Answers0