Reputation: 443
I have my C# WinForm application that runs another "devcon.exe" console application with admin rights:
var startInfo = new ProcessStartInfo
{
FileName = fileName, // filename C:\....\devcon.exe
WindowStyle = ProcessWindowStyle.Hidden, // we don't want to see devcon.exe window
Arguments = "restart " + deviceID, // some arguments for devcon.exe console application
Verb = "runas" // run as administrator
};
Process.Start(startInfo).WaitForExit();
So, GUI UAC prompt is shown every time when devcon.exe is started.
But users don't want to see GUI UAC prompt every time. It is acceptable to show GUI UAC prompt only one time while first start the devcon.exe
runas.exe with /savecred can help to save admin password and ask it only one time while first start the devcon.exe:
Process.Start("cmd.exe", @"/C runas.exe /savecred /user:" + "admin" + " " + "\"C:\...\devcon.exe restart " + deviceID + "\"");
But console prompt is shown in this case (it asks for admin password).
Users don't want to see console prompt, they want to see GUI UAC prompt. How can I show GUI UAC prompt instead of console prompt in this case? If it is impossible with runas.exe with /savecred, how can I save admin password to ask only one time while first start the devcon.exe?
P.S. I don't know admin password, user should enter it by himself.
Upvotes: 0
Views: 1214
Reputation: 11
As stated by KooKiz you can ask your user to start the main process as administrator so it no longer prompts UAC for the other programs it's going to run.
How to request administrator permissions when the program starts?
Upvotes: 0