Tuesday, May 24, 2016

Run Program as Administrator programmatically

I need to run a program as Administrator programmatically.

Fortunately googling this was so easy. Found this one:
Run Program As Administrator in vb.net


Open the Project Properties then click on View Windows Setting button. It will open the app.manifest file.



Quote from the site:

You can do the following to make sure the program has admin permissions:
You can edit the UAC Settings (in VB 2008) which is located in the Project Settings. Look for the line that says

Change level="asInvoker" to:
level="asInvoker" (normal account - default)
level="requireAdministrator (require administrator - What you need... but could be next one)
level="highestAvailable" (if anything is higher then administrator, require that)

Hope it helps :)

So what i need to change is this:

to level="highestAvailable".

But I get this error when build:

ClickOnce does not support the request execution level 'highestAvailable'.

Well, I am using ClickOnce. I try changing it to "requireAdministrator ". But no luck also. I conclude that this setting is not permitted via ClickOnce. And I think if not via ClickOnce, it will really works.

No comments:

Post a Comment