Design Flow: Non-Admin User ----> Program A (Non-Admin) --> Program B (Requires Admin)
I'm writing a program to launch a program that requires admin rights from a non-admin account. The program is launched on start-up with any user and it launches the second program (requiring admin rights) as a different user who has admin rights. The issue I am having is the program is saying that to launch a program as a different user it requires admin rights. I know this not to be true so I know I have something incorrect in my code to launch the second process.
The code is as follows:
try
{
ProcessStartInfo myProcess = new ProcessStartInfo(path);
myProcess.UserName = username;
myProcess.Password = MakeSecureString(password);
myProcess.WorkingDirectory = @"C:\Windows\System32";
myProcess.UseShellExecute = false;
myProcess.Verb = "runas"; //Does not work with or without this command
Process.Start(myProcess);
}
The exception is as follows:
System.ComponentModel.Win32Exception (0x80004005): The requested operation requires elevation
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Loader.Program.RunProgram(String path, String username, String password)