How to make a .exe file programmatically launched as an administrator always in Vista?

I wrote a winform application in C #. When I run the program for some functions, it needs administrator permission. After installation If I installed the .exe file to run as an administrator manually (by right-clicking on the .exe file), then my program will work fine.

Now I need the user to not set the launch as the admin property after installation by right-clicking. I need to install this program code somewhere in code that the user does not need to worry about. This specific problem occurs only for Windows Vista. Can anyone help me out?

0
source share
2 answers

You need to add a manifest to the application, which indicates that it requires administrator privileges. Learn more about MSDN .

Refresh . You can add a manifest to your project by right-clicking on the project and selecting Add/ New Item/ Application Manifest File. This will add a new file called app.manifest to your project and will refer to it from the project properties in the drop-down list Manifeston the tab Application. The default manifest template even has nice comments on how to fine-tune the required level of UAC execution.

+4
source

You need to specify requestExecutionLevel in the manifest.

. : http://petesbloggerama.blogspot.com/2007/04/making-your-assembly-run-as.html

0

All Articles