I\'m trying to start an elevated process from with a non-elevated process, but I also need to supply the username and password for a user with administrative credentials. I\'ve
According to the MSDN documentation:
When UseShellExecute is false, you can start only executables by using the Process object.
I noticed your declaration var proc = Process.Start(info);
is not using Process
as the class type.
Also make sure parameter path
is the fully qualified path to the executable. For instance, "c:\\directory\\contains\\process_to_be_started\\executable.exe"
According to the MSDN documentation this is important:
The WorkingDirectory property must be set if UserName and Password are provided. If the property is not set, the default working directory is %SYSTEMROOT%\system32.
I would try below code to run target process with elevated privileges (with admin rights).
ProcessStartInfo info = new ProcessStartInfo(path);
info.UseShellExecute = false;
info.UserName = username;
info.Password = securePwd;
info.Domain = "MyDomain";
info.Verb = "runas";
info.WorkingDirectory = "c:\\directory\\contains\\process_to_be_started"
'var proc = Process.Start(info);
Process proc = Process.Start(info);