views:

50

answers:

2

I have written a winform application in C#. When I run the program for some functionality it required admin permission. After Installation If I set the .exe file to run as admin manually (by clicking right mouse button on .exe file) then my program run perfectly.

Now I need user not to set the run as admin property after installation by clicking right mouse button. I need to set this programaticaly somewhere in the code that user no need to bother about this. This specific problem is only arise for Windows Vista. Can anyone help me out?

+1  A: 

You need to add a manifest to the app that specifies it require admin privileges. Read more on MSDN.

Update: 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 reference it from the project properties, in the Manifest dropdown on the Application tab. The default manifest template even has a nice comments on how exactly to change the required UAC execution level.

Franci Penov
Thanx for quick reply. But I could not find a way to create a manifest file in Visual Studio 2008 for my Win form application. Can you help?
Iftekher Islam
A: 

You need to specify the requestedExecutionLevel in the manifest.

See here for a detailed explanation: http://petesbloggerama.blogspot.com/2007/04/making-your-assembly-run-as.html

malloc