0

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.

Evgeniy
  • 403
  • 1
  • 8
  • 18

1 Answers1

0

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?

Community
  • 1
  • 1
Erendar
  • 11
  • 1
  • It works, but the problem is I can't start my application with admin rights (users may not have admin rights, but they should have ability to use my application). It is acceptable to ask for admin password only while installation app process. – Evgeniy Dec 19 '14 at 15:46
  • Some applications use an helper service. A service install requires admin rights and can be set up to run as Local Machine (somewhat higher/equal permission of admin). You could run yourself a service and ask him to run "xxx" for you as elevated. – Erendar Jan 09 '15 at 15:10