views:

57

answers:

2

I wrote a simple c++ application in Visual Studio 2005 but when I compile it, the executable wants to run as admin. I tried deleting the manifest but it still wants to run as admin. I am running Windows Vista Home premium. Any help would be appreciated!

A: 

Windows will ask you for the administrator password if the name of your executable "looks like" a name of a setup program. Name you executable setup.exe and you will be prompted for password every time you run it. What is the name of your executable?

AndreyT
The name was "patch program.exe", I changed it to "abc.exe" and it no longer wants to run as administrator. I did some testing and discovered that if the name contains "patch" then it automatically tries to run as administrator. Thank you alot because it is unlikley I would have figured it out.
A: 

To prevent these heuristics from guessing for you, put a manifest on your application. From Visual Studio 2005 it is harder than from Visual Studio 2008. I have instructions at http://www.gregcons.com/KateBlog/AddingAManifestToAVistaApplication.aspx that elaborate on those at http://blogs.msdn.com/cheller/archive/2006/08/24/how-to-embed-a-manifest-in-an-assembly-let-me-count-the-ways.aspx - these are for VS 2005, for C#, VB, and C++. If your app has an asInvoker manifest it will no longer elevate even if it's named Setup.exe or Patch.exe.

Kate Gregory
Thanks for the information!