Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProcessStartInfo Verb runas not working

Tags:

c#

wpf

What is wrong with the following code?

        ProcessStartInfo startInfo = default(ProcessStartInfo);

        startInfo = new ProcessStartInfo(SetupProgramPath)
        {
            UseShellExecute = true,
            Verb = "runas",
            WindowStyle = ProcessWindowStyle.Normal,
            CreateNoWindow = false
        };

        Process.Start(startInfo); 

It is expected to prompt for credentials but nothing shows up. The system has the UAC enabled and not supposed to be changed. I appreciate your help in this one. Thank you in advance.

like image 637
Sunder Avatar asked Feb 21 '26 23:02

Sunder


1 Answers

I have worked this out with the following code

ProcessStartInfo startInfo = default(ProcessStartInfo);

startInfo = new ProcessStartInfo(SetupProgramPath)
{
    UseShellExecute = true,
    Verb = "runas",
    WindowStyle = ProcessWindowStyle.Normal,
    FileName = "msiexec",
    Arguments = "/i \"" + SetupProgramPath + "\"",
    CreateNoWindow = false
};

Process.Start(startInfo); 
like image 125
Sunder Avatar answered Feb 24 '26 11:02

Sunder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!