Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Reason for UAC prompt , porting for Win7

Reason for UAC prompt , porting for Win7

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpjavacomquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Moak
    wrote on last edited by
    #1

    Hi, I wrote two C++ Windows applications which I previously used on WinXP. The main MFC application gets no UAC prompt when I start it, works fine on Win7. The Win32 application, which is just a WinMain() with some functionality, gets an UAC prompt as soon as I double click it. Can I find out why? Thanks, let me know if I should provide more details!

    Chat in Europe :java: Now with 24% more Twitter

    E K 2 Replies Last reply
    0
    • M Moak

      Hi, I wrote two C++ Windows applications which I previously used on WinXP. The main MFC application gets no UAC prompt when I start it, works fine on Win7. The Win32 application, which is just a WinMain() with some functionality, gets an UAC prompt as soon as I double click it. Can I find out why? Thanks, let me know if I should provide more details!

      Chat in Europe :java: Now with 24% more Twitter

      E Offline
      E Offline
      Eugen Podsypalnikov
      wrote on last edited by
      #2

      What does the check box "Run as administrator" show (in the "Compatibility" property page of the result exe), please ? :) Here is an example of "any-user" manifest, that could be bind to an exe:

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
      <security>
      <requestedPrivileges>
      <requestedExecutionLevel
      level="asInvoker"
      uiAccess="false"
      />
      </requestedPrivileges>
      </security>
      </trustInfo>
      <dependency>
      <dependentAssembly>
      <assemblyIdentity
      type="win32"
      name="Microsoft.Windows.Common-Controls"
      version="6.0.0.0"
      processorArchitecture="X86"
      publicKeyToken="6595b64144ccf1df"
      language="*"
      />
      </dependentAssembly>
      </dependency>
      </assembly>

      virtual void BeHappy() = 0;

      M 1 Reply Last reply
      0
      • E Eugen Podsypalnikov

        What does the check box "Run as administrator" show (in the "Compatibility" property page of the result exe), please ? :) Here is an example of "any-user" manifest, that could be bind to an exe:

        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
        <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
        <requestedPrivileges>
        <requestedExecutionLevel
        level="asInvoker"
        uiAccess="false"
        />
        </requestedPrivileges>
        </security>
        </trustInfo>
        <dependency>
        <dependentAssembly>
        <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="X86"
        publicKeyToken="6595b64144ccf1df"
        language="*"
        />
        </dependentAssembly>
        </dependency>
        </assembly>

        virtual void BeHappy() = 0;

        M Offline
        M Offline
        Moak
        wrote on last edited by
        #3

        "Run as administrator" is not enabled. Can you give me some background on the manifest? Does every executable need one under Win7 in order to avoid UAC prompt... or is it some API call inside my exe which causes the UAC prompt?

        Chat in Europe :java: Now with 24% more Twitter

        E 1 Reply Last reply
        0
        • M Moak

          "Run as administrator" is not enabled. Can you give me some background on the manifest? Does every executable need one under Win7 in order to avoid UAC prompt... or is it some API call inside my exe which causes the UAC prompt?

          Chat in Europe :java: Now with 24% more Twitter

          E Offline
          E Offline
          Eugen Podsypalnikov
          wrote on last edited by
          #4

          // or is it some API call inside my exe which causes the UAC prompt? May be... ...when it (test) will not help : - save the XML-dump as c:\yours.manifest - set the exe-VS\ProjektProperty\Manifest Tool\Input and Output\Additional Manifest Files to c:\yours.manifest - rebuild An "admin" API call would just fail, I think, by filled LastError (about some rights) in the "non-admin" modus... :)

          virtual void BeHappy() = 0;

          M 1 Reply Last reply
          0
          • M Moak

            Hi, I wrote two C++ Windows applications which I previously used on WinXP. The main MFC application gets no UAC prompt when I start it, works fine on Win7. The Win32 application, which is just a WinMain() with some functionality, gets an UAC prompt as soon as I double click it. Can I find out why? Thanks, let me know if I should provide more details!

            Chat in Europe :java: Now with 24% more Twitter

            K Offline
            K Offline
            krmed
            wrote on last edited by
            #5

            It could simply be the name of your exe file also. Vista (and Windows 7) UAC also uses heuristics to determine if an application needs admin privilege. See this article[^] on MSDN (especially the "Installer Detection" part). Even strings in the string table of your application can trigger UAC. Hope that helps.

            Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

            M 1 Reply Last reply
            0
            • K krmed

              It could simply be the name of your exe file also. Vista (and Windows 7) UAC also uses heuristics to determine if an application needs admin privilege. See this article[^] on MSDN (especially the "Installer Detection" part). Even strings in the string table of your application can trigger UAC. Hope that helps.

              Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

              M Offline
              M Offline
              Moak
              wrote on last edited by
              #6

              krmed wrote:

              UAC also uses heuristics to determine if an application needs admin privilege.

              Yes that's it! The file is a software_updater.exe, the text "update" in file name or version info triggers the "installer detection". Now have to find a way around that, I am curious if I can do the following: 1) keep file name without UAC prompt, 2) elevate privileges on runtime when actually needed. Most time my software updater justs needs to run with normal user rights, only when the main application is updated it would need more privileges. Btw, if someone is interested, I would have never mentioned the problem if my MSI installer wouldn't have failed. You can't run (non-deferred) custom actions which will then trigger a UAC prompt, they fail silently. Thanks for the info! :)

              Chat in Europe :java: Now with 24% more Twitter

              1 Reply Last reply
              0
              • E Eugen Podsypalnikov

                // or is it some API call inside my exe which causes the UAC prompt? May be... ...when it (test) will not help : - save the XML-dump as c:\yours.manifest - set the exe-VS\ProjektProperty\Manifest Tool\Input and Output\Additional Manifest Files to c:\yours.manifest - rebuild An "admin" API call would just fail, I think, by filled LastError (about some rights) in the "non-admin" modus... :)

                virtual void BeHappy() = 0;

                M Offline
                M Offline
                Moak
                wrote on last edited by
                #7

                Thanks for the info! However, the manifest with trustinfo was not enough, also needed Win7 compability for UAC to work as wanted (they changed the rules for Win7). Didn't expect me to say that... but this mess wouldn't have happened with Bill Gates still being at Microsoft. :)

                Chat in Europe :java: Now with 24% more Twitter

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups