locked
This operation requires elevation (but why?) RRS feed

  • Question

  •  

    The answer may seem obvious to many people but I cannot figure out why this is happening. I am peforming some tests to see how close we are to be "compatible" with the UAC service. I have installed my application on a Windows Vista machine, and apparently it works fine (minor problems) as-is. As-is means that it runs in legacy-mode (picked that term in a newsgroup don't know if it is correct) meaning there is no manifest.

    Then I add an external manifest that requests execution level "asInvoker". Everythings goes fine (well most things). I manually addeed the external manifest in program files directory after installation.

     

    And then I try to see what happens when I change to "requireAdministrator". What I would expect is to be promted for consent (I may a member of the local Administrator group). This is what typically happens in other applications I have tried. But instead of getting a prompt asking me "A program requires bla-bla..." I get a dialog that says "This operation requires elevation". Surely it does, and I will give my permission but it doesn't ask me at all. If I "Run as administrotor" my app kicks-off propertly. What am I doing wrong? I actually sat and wrote a hello world app with a simple VS 2005 setup project, performed the same steps and the Hello world app has different behaviour. It asks me for permission since it is requireAdministrator.

     

    Does anybody know what am I doing wrong?

    Thursday, March 22, 2007 10:10 AM

Answers

  • One possible explanation for this could be that Vista does lot of caching - including manifests for performance reasons. Its called supercaching. Sometimes it results in strange behavior in a dev environment.

     

    Rename the external manifest and then run your application couple of times. And then rename it back to the original name. See if that causes the cache to be updated. 

     

    Curious to see if that was the issue or not.

    Tuesday, March 27, 2007 3:54 AM

All replies

  • Elevation prompting only happens if the creation of the process is triggered by ShellExecute(Ex).
    I assume you have used a straightforward CreateProcess call.

    Thursday, March 22, 2007 10:55 PM
  • I do not spawn any process. My app is a plain executable triggered by the Start Menu (explorer.exe I suppose). I click the executable icon as usual. Is there anything else I should check? Thanks
    Friday, March 23, 2007 8:53 AM
  • One possible explanation for this could be that Vista does lot of caching - including manifests for performance reasons. Its called supercaching. Sometimes it results in strange behavior in a dev environment.

     

    Rename the external manifest and then run your application couple of times. And then rename it back to the original name. See if that causes the cache to be updated. 

     

    Curious to see if that was the issue or not.

    Tuesday, March 27, 2007 3:54 AM
  • Amazing! Where did you get that? Thanks a lot
    Tuesday, March 27, 2007 8:48 AM
  • 
    Amazing! Where did you get that? Thanks a lot

    The OS looks at the file modification time, compares it against the cached version  and loads the latest version available, so when adding a manifest, make sure you "touch" the file.
     
    Willy.
     
    PS. Touching means update the file "date modified".
     
    Tuesday, March 27, 2007 6:53 PM