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. By default run an exe in run as admin mode using MFC

By default run an exe in run as admin mode using MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
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.
  • A Offline
    A Offline
    Abinash Mohanty
    wrote on last edited by
    #1

    Hi, Can anybody tell me how to run an exe by default in Run as Admin mode irrespective of the user.Please help me with the source code in mfc.

    _ 1 Reply Last reply
    0
    • A Abinash Mohanty

      Hi, Can anybody tell me how to run an exe by default in Run as Admin mode irrespective of the user.Please help me with the source code in mfc.

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

      This can be controlled using the manifest file for your project. You will the .manifest file which is an XML file in your debug or release folder depending on you current configuration. There is a node called requestedExecutionLevel that controls this. By default this will be asInvoker. The available options here are -

      requireAdministrator
      asInvoker
      highestAvailable

      Using these levels, you can tell how the application must start.

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

      A 1 Reply Last reply
      0
      • _ _Superman_

        This can be controlled using the manifest file for your project. You will the .manifest file which is an XML file in your debug or release folder depending on you current configuration. There is a node called requestedExecutionLevel that controls this. By default this will be asInvoker. The available options here are -

        requireAdministrator
        asInvoker
        highestAvailable

        Using these levels, you can tell how the application must start.

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

        A Offline
        A Offline
        Abinash Mohanty
        wrote on last edited by
        #3

        Thanks for your reply.I tried to edit the .manifest file.But its changing after each build.Can you please tell me the whole process how to do it?

        B _ 2 Replies Last reply
        0
        • A Abinash Mohanty

          Thanks for your reply.I tried to edit the .manifest file.But its changing after each build.Can you please tell me the whole process how to do it?

          B Offline
          B Offline
          BIJU Manjeri
          wrote on last edited by
          #4

          You can change that by using Projects Settings menu in VS IDE Project Settings > Linker > Manifest File or refer http://vctipsplusplus.wordpress.com/2009/10/21/windows-privileges-issues[^] :)

          1 Reply Last reply
          0
          • A Abinash Mohanty

            Thanks for your reply.I tried to edit the .manifest file.But its changing after each build.Can you please tell me the whole process how to do it?

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

            Sorry that I didn't tell you how to do it. Take Project Properties -> Configuration Properties -> Linker -> Manifest File -> UAC Execution Level. Here you have a drop down box from which you can make your selection.

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

            A 1 Reply Last reply
            0
            • _ _Superman_

              Sorry that I didn't tell you how to do it. Take Project Properties -> Configuration Properties -> Linker -> Manifest File -> UAC Execution Level. Here you have a drop down box from which you can make your selection.

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

              A Offline
              A Offline
              Abinash Mohanty
              wrote on last edited by
              #6

              Hi, Thanks again for your reply . I changed the settings of the project according to you.But it didn't solve my problem.I am explaining my problem to you in details.I want to access the hard disk of my system without being logged on as Administrator.I have created another user,but its unable to retrieve the handle of my hard disk. If I am running my application as Admin and giving the password then its working fine. I hope I have successfully explained you my problem.Please give a solution to my problem.

              _ 1 Reply Last reply
              0
              • A Abinash Mohanty

                Hi, Thanks again for your reply . I changed the settings of the project according to you.But it didn't solve my problem.I am explaining my problem to you in details.I want to access the hard disk of my system without being logged on as Administrator.I have created another user,but its unable to retrieve the handle of my hard disk. If I am running my application as Admin and giving the password then its working fine. I hope I have successfully explained you my problem.Please give a solution to my problem.

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

                Only a process with administrative privileges will be able retrieve a handle to the hard disk. If the user is not an admin, you will have to give the admin privileges (username and password) for it to work. If any other way was possible, it would be a security breach.

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

                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