views:

73

answers:

4

I'm running VS2K8 in Win7 64-bit. I'm logged in as admin and I'm running it as admin, but the program I'm working on fails with access denied when I call a restricted API. If run the program from Explorer with "Run as Administrator" it works.

I was under the belief that VS2K8 debugs programs with whatever rights VS2K8 itself is running with. As it stands I can't debug my application due to this and I'm at a loss as to what's going on.

+1  A: 

Run VS2008 as administrator.

ZippyV
A: 

My testing with Vista and VS2005 showed that when you use a host process, the behavior under the debugger depends only on how you launched Visual Studio and not on the manifest (or lack of manifest) of your application. When Visual Studio is launched elevated, the behavior depends only on the use (or not) of a host process, not on the manifest. This is probably still true with Windows 7 and VS2008.

Also, have you tried launching the app outside VS and using Attach to Process?

Kate Gregory
+1  A: 

I found the answer. Turns out that it is, in fact, a manifest issue -- by default if you have a manifest you need to set the appropriate admin privilege. The default is "asInvoked" but that doesn't work if you need elevated privileges, you instead have to set it to "as Administrator" (or something like that) in the Manifest properties.

brian
asInvoker, not asInvoked. And the other is requireAdministrator.
Kate Gregory
+2  A: 

It's best to run VS2008 studio as administrator. Moreover, it's good to change your application's manifest settings to require administrator privileges. You will be prompted by the system to elevate to admin each time you start your app and when running under VS2008 the IDE will offer you the elevetion before start of debugging.

To change the setting open project properties and go to Configuration Properties -> Linker -> Manifest file -> UAC Execution Level.

AOI Karasu

related questions