3

I want to test the installation of the application.And use next code:

            var pathToInstaller = ConfigurationManager.AppSettings["DesignerApp"];
            var psi = new ProcessStartInfo
            {
                CreateNoWindow = true,
                FileName = pathToInstaller,
                UseShellExecute = true,
                Arguments = "/quiet",
                Verb = "runas"             
            };

            var process = Process.Start(psi);
            process.WaitForExit();

But still there is a window with the presentation of the rights of the administrator.What am I doing wrong?

Chris
  • 5,882
  • 2
  • 32
  • 57
  • 9
    You *can't* start a process as an admin behind the user's back. Otherwise every virus and malware would be able to bypass admin checks – Panagiotis Kanavos May 31 '16 at 09:09
  • How about this sophisticate solution. Add new Windows Service and which will work under System service account. It will receive command for starting new program and call [CreateProcessAsUserW](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682429%28v=vs.85%29.aspx) to start process for needed user. – Artavazd Balayan May 31 '16 at 10:39
  • 2
    This is not possible. You need to **ASK** the user to give admin rights. – Vahid Amiri May 31 '16 at 11:51
  • Why do you think that it is not possible? Program will start under **System Service account** with CreateProcessAsUserW – Artavazd Balayan May 31 '16 at 18:13
  • The reason this is not (easily) possible is to make the system more secure by making it harder for malware to get unnoticed... So don't expect much help to goes around security Microsoft has added to the OS. **Nobody should buy your software if you don't respect the rules.** – Phil1970 Nov 18 '17 at 14:21

1 Answers1

0

For security reasons, you technically shouldn't force an application to run in administrator mode. But if you want to go ahead with it, you can check out this link - How do I force my .NET application to run as administrator?

P.Rao
  • 96
  • 1
  • 5