-1

I am trying to run an exe inside a console application. I am being prompted for UAC to enter admin credentials. The thing is i only have read and execute permissions. I cannot give full permissions as it is on a server.

using (Process process = new Process())
{
    process.StartInfo.Verb = "runas";
    process.StartInfo.FileName = ImgToDjvuPath;
    process.StartInfo.Arguments = string.Format("\"{0}\" -profile \"{1}\" \"{2}\"  \"{3}\"", ImgToDjvuPath, "fine200up", localNewDjvuFile, localNewDjvuFile);
    process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    process.StartInfo.CreateNoWindow = true;
    process.Start();
    process.WaitForExit(10 * 60 * 1000);

}

I want to be able to run this code and have it work without being prompted for uac.

This is why i do not like stack overflow, you ask a specific question and rarely get a specific answer. Then get marked down for asking a valid question. I figured it out about 2 minutes after i posted. Thanks to those to actually tried to help for being constructive and helping.

  • isn't it a windows setting somewhere? like [here](https://articulate.com/support/article/how-to-turn-user-account-control-on-or-off-in-windows-10) – Corentin Pane Feb 11 '20 at 08:38
  • 2
    why are you using `runas` verb if you do not want utility to be executed as admin ? – Manoj Choudhari Feb 11 '20 at 08:39
  • 2
    You can't run something like an admin if you don't have admin privileges. – Liam Feb 11 '20 at 08:43
  • If the executable requires elevation to run, you must execute the executable from a process that already has elevation or you need to manually elevate the process when prompted. – Kieran Devlin Feb 11 '20 at 08:43
  • it doesnt, read and execute should be enough –  Feb 11 '20 at 09:02
  • @ManojChoudhari i think you are correct –  Feb 11 '20 at 09:03
  • Remote `process.StartInfo.Verb = "runas";`. That is how you trigger a prompt to ask an administrator to enter their credentials. – Ian Boyd Mar 16 '20 at 02:51

1 Answers1

1

If you want to start a new process and if you want process to run as administrator, you need RunAs verb.

UAC prompt will be shown ONLY IF the process invoker does not have administrative rights.

For your case, if you do not want process to be executed as Admin, then you should remove below line from the code:

process.StartInfo.Verb = "runas";
Manoj Choudhari
  • 5,277
  • 2
  • 26
  • 37