So I tried Googling this and this does not get a good result. What Im trying to do is run another program as an administrator without that annoying UAC popping up everytime.
The idea is this, this program requires administrator privileges to run which the user will grant. Then this program will run a bunch of other programs that also require administrator permissions. Instead of the user clicking and allowing a bunch of programs time to time, the program with admin permissions can run the other programs as administrator since itself has it.
This would save the user from following way to many instructions. Also, having the program request the user to allow many things looks very unprofessional. Its just a one-click program that does it all.
The reason why I said Google is not getting a good result is because the page is flooded with how users can run their program AS an administrator. I want to be able to run another program as an admin.
I was thinking of dropping the setup files on a folder and then running the files as admin from CMD but it would require me to use runas
and after testing it on myself, it kept saying that the password/username was wrong yet I was sure it was.
Any other tips?
You can run another application from your application by using:
Process.Start("Notepad.exe")
If your original program is running Elevated (As Admin), then Notepad will run As Admin (there will be no UAC prompt)
If your original program is not running Elevated and you want to start an application elevated (As Admin) you will have to do something like this (this will prompt for elevation):
Dim procStartInfo As New ProcessStartInfo
Dim procExecuting As New Process
With procStartInfo
.UseShellExecute = True
.FileName = "Notepad.exe"
.WindowStyle = ProcessWindowStyle.Normal
.Verb = "runas" 'add this to prompt for elevation
End With
procExecuting = Process.Start(procStartInfo)
Note that there is no way to circumvent the UAC prompt. If UAC is enabled then the user will have to agree to the elevation at some point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With