I am working on a small application in VB.NET. The program needs administrator privilege for doing some tasks. Is there a way to ask for administrator privileges during the execution if the program?
What is the general way of changing the user account under which the application is running?
The most easy way to do this is to click on the Project tab -> Add Windows Form -> .XML file -> name it (program name).manifest -> paste this code in this link into it ( thanks JDOConal ) -> then right click on your project name in the solution explorer box off to the right and hit properties -> on the first tab select manifest and then the .manifest file you created -> build = done!
You can specify this in your application's manifest file.
Check out this link and this link and this link too.
There are a number of methods depending on your needs. Some details are given in the application developer requirements for UAC.
CoCreateInstanceAsAdmin
to call methods on a COM object running as an administrator. This is possibly tricky to get working in VB.Net. I got it working ok in C++ though