views:

250

answers:

3

Hi,

I am trying to build an automation application in C# 2005 express edition under windows vista. Problem is, Whenever I try to run this application, either from IDE or directly compiled executable under vista, it asks for elevated admin privileges, same executable runs under XP normally though!

I'm unable to understand if this problem due to manifest or something else...

Thanks,

+3  A: 

Firstly, I would update to 2008 Express; 2005 Express is no longer available for download, but 2008 Express can still target .NET 2.0, in addition to giving you 3.0/3.5 goodness. And it is still free. Actually, 2010 Express is just around the corner! In particular, you'll find it increasingly hard to find people who can answer 2005 Express IDE-specific issues, simply because few people have 2005 Express still installed.


Add an application manifest file (via the IDE) - it will appear as app.manifest; it should add (by default):

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

Which should (IIRC) help - but a: where is the app running from, and b: what does it do? (does it try to edit the registry, etc).

Marc Gravell
Thanks Marc for reply but I tried this solution before posting this here but it didn't solved my problem. :(
Bhavesh.Bagadiya
+3  A: 

Additionally to Marc's answer: If the executable has i.e. 'setup' or 'install' as part of it's name, the UAC asks for admin privileges regardless of a manifest. The only work around that is to rename the .exe to something that does not contain these keywords.

Edit: 'Update' is such a keyword too. Please see also this Technet article about UAC.

Sebastian P.R. Gingter
Interesting, didn't know that. Out of curiosity though, have you a source for that info?
RCIX
Is described in the technet:http://technet.microsoft.com/en-us/library/cc709628(WS.10).aspxAlso 'update' is such a keyword.
Sebastian P.R. Gingter
A: 

If your application attempts to do things that require elevated privileges (e.g. write to the Program Files folder or some areas of the registry), it will need to ask for elevation or it'll fail. Under XP it won't ask for elevation at all; it'll just fail if it doesn't have the permissions it needs to run (but usually people run with administrative privileges under XP, so this isn't often a problem)

To add one "gotcha" to the existing answers: If you use the file properties (Compatibility tab) on your .exe to force it to "run as administrator", it will always ask for elevation when it is run. Unintuitively, this is applied permanently to the pathname, so even if you delete the .exe and install a new one, the "as admin" setting will still apply! You have to specifically open the properties and disable that property to remove it again.

Jason Williams