1
votes

I have an exe that a normal user will run, but it needs to merge a REG file, which requires UAC popup asking for the admin password, which I do not want to provide to user.

Is there a way for me to pass in the password in process.StartInfo so UAC doesn't have to ask for the password?

If I do this:

process.StartInfo.Domain    = "XYZ";
process.StartInfo.UserName  = "admin";
process.StartInfo.Password  = "";

It tells me I need to be evelated.

I have also tried to impersonate the admin account, then:

process.StartInfo.Verb      = "runas";
process.start() 

But it will crash with:

Unhandled Exception: System.ComponentModel.Win32Exception: Unknown error (0xfffffffe)

1

1 Answers

1
votes

No, you can't do that. If you could easily bypass UAC, there would be no point in it.

The thing is even if you know the password, the security token is created with dropped privileges. This is what happens when you login to Windows: you provide username and password but you don't get the whole range of administrator privileges right away, you have to elevate via UAC confirmation.