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. How to run an app in admin mode in Vista and 7

How to run an app in admin mode in Vista and 7

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
5 Posts 4 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.
  • P Offline
    P Offline
    Patcher32
    wrote on last edited by
    #1

    I have seen some applications warn that you have to run it in admin mode, if you do not run it in admin mode in both Windows Vista and 7. How do they detect if it is running with admin privileges or not. Some application even invoke the UAC (user access control) dialog to pop up, as soon as they run. Please someone enlighten me about this.

    K _ K 3 Replies Last reply
    0
    • P Patcher32

      I have seen some applications warn that you have to run it in admin mode, if you do not run it in admin mode in both Windows Vista and 7. How do they detect if it is running with admin privileges or not. Some application even invoke the UAC (user access control) dialog to pop up, as soon as they run. Please someone enlighten me about this.

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

      It's not the application that detects if you're running as admin or not, it's the OS. Any user of Vista/Windows 7 (including Administrator) by default do not run with admin privilege - it must be requested. Certain actions require admin rights - like writing to HKEY_LOCAL_MACHINE in the registry or creating files within the Program Files directory (and sub-directories)., You can make your app show that UAC dialog and request admin rights by using the following manifest file.

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="YourApp" type="win32"/>
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
      <security>
      <requestedPrivileges>
      <requestedExecutionLevel level="requireAdministrator"/>
      </requestedPrivileges>
      </security>
      </trustInfo>
      </assembly>

      Save this file in the folder containing your app with the same name as your app and the extension of .manifest. For instance, if your app is called MyTestApp.exe, save this file as MyTestApp.exe.manifest. Now when you run the app it will pop up the UAC dialog. 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

      1 Reply Last reply
      0
      • P Patcher32

        I have seen some applications warn that you have to run it in admin mode, if you do not run it in admin mode in both Windows Vista and 7. How do they detect if it is running with admin privileges or not. Some application even invoke the UAC (user access control) dialog to pop up, as soon as they run. Please someone enlighten me about this.

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        This article tell you how it is done - Adding UAC elevation manifest in Visual C++ 8.0/ Visual Studio 2005 C or C++ project[^]

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        1 Reply Last reply
        0
        • P Patcher32

          I have seen some applications warn that you have to run it in admin mode, if you do not run it in admin mode in both Windows Vista and 7. How do they detect if it is running with admin privileges or not. Some application even invoke the UAC (user access control) dialog to pop up, as soon as they run. Please someone enlighten me about this.

          K Offline
          K Offline
          Kushagra Tiwari
          wrote on last edited by
          #4

          U need to embed a   manifest in your application which will allow your application to be recognized by vista to run as administrator : This link will give us step by step solution for the same . http://social.msdn.microsoft.com/forums/en-US/windowssecurity/thread/6d870287-e364-4151-851d-70605c0e6a6d/[^] Hope it helps and solves ur purpose. Regards, Kushagra

          P 1 Reply Last reply
          0
          • K Kushagra Tiwari

            U need to embed a   manifest in your application which will allow your application to be recognized by vista to run as administrator : This link will give us step by step solution for the same . http://social.msdn.microsoft.com/forums/en-US/windowssecurity/thread/6d870287-e364-4151-851d-70605c0e6a6d/[^] Hope it helps and solves ur purpose. Regards, Kushagra

            P Offline
            P Offline
            Patcher32
            wrote on last edited by
            #5

            No. Adding manifest is not the solution. I think its the process properties that one should look into.

            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