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. UAC and restarting an external service in my MFC app

UAC and restarting an external service in my MFC app

Scheduled Pinned Locked Moved C / C++ / MFC
c++comsysadminsecuritybusiness
4 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.
  • S Offline
    S Offline
    Sternocera
    wrote on last edited by
    #1

    Hi, I have an MFC app that is dependant on an external windows service. The need to restart that service occasionally arises. I do this using some boilerplate code, heavily derivative of that appearing in an article on MSDN. When I run the application on Vista as a non-administrator, a call to OpenSCManager() returns NULL. I must run the application as an administrator for the process to succeed. Can I make a UAC dialog automatically appear on Vista/7 in the event of needing to access administrative functions like this? I have similar problems in the same application when calling code that uses boost.asio to ping a remote server. I'm not sure if it's relevant, but here is my application manifest security entry:

    <!-- Identify the application security requirements. -->
    <ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-
    com:asm.v2">
    <ms_asmv2:security>
    <ms_asmv2:requestedPrivileges>
    <ms_asmv2:requestedExecutionLevel level="highestAvailable">
    </ms_asmv2:requestedExecutionLevel>
    </ms_asmv2:requestedPrivileges>
    </ms_asmv2:security>
    </ms_asmv2:trustInfo>

    Thanks a lot, Sternocera

    M 1 Reply Last reply
    0
    • S Sternocera

      Hi, I have an MFC app that is dependant on an external windows service. The need to restart that service occasionally arises. I do this using some boilerplate code, heavily derivative of that appearing in an article on MSDN. When I run the application on Vista as a non-administrator, a call to OpenSCManager() returns NULL. I must run the application as an administrator for the process to succeed. Can I make a UAC dialog automatically appear on Vista/7 in the event of needing to access administrative functions like this? I have similar problems in the same application when calling code that uses boost.asio to ping a remote server. I'm not sure if it's relevant, but here is my application manifest security entry:

      <!-- Identify the application security requirements. -->
      <ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-
      com:asm.v2">
      <ms_asmv2:security>
      <ms_asmv2:requestedPrivileges>
      <ms_asmv2:requestedExecutionLevel level="highestAvailable">
      </ms_asmv2:requestedExecutionLevel>
      </ms_asmv2:requestedPrivileges>
      </ms_asmv2:security>
      </ms_asmv2:trustInfo>

      Thanks a lot, Sternocera

      M Offline
      M Offline
      Mohan Ramachandra
      wrote on last edited by
      #2

      This one might help

      Sternocera wrote:

      ms_asmv2:requestedExecutionLevel level="highestAvailable"

      change to ms_asmv2:requestedExecutionLevel level="highestAvailable" uiAccess="true"

      B S 2 Replies Last reply
      0
      • M Mohan Ramachandra

        This one might help

        Sternocera wrote:

        ms_asmv2:requestedExecutionLevel level="highestAvailable"

        change to ms_asmv2:requestedExecutionLevel level="highestAvailable" uiAccess="true"

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

        For that, you must set UAC options for your projects. linker option in the Visual Studio development environment must be changed. ->Open the project's Property Pages dialog box. ->Expand the Configuration Properties node. ->Expand the Linker node. ->Select the Manifest File property page. Modify the 1.Enable User Account Control (UAC)-Yes 2.UAC Execution Level-highestAvailable 3.UAC Bypass UI Protection properties-Yes BIJU

        1 Reply Last reply
        0
        • M Mohan Ramachandra

          This one might help

          Sternocera wrote:

          ms_asmv2:requestedExecutionLevel level="highestAvailable"

          change to ms_asmv2:requestedExecutionLevel level="highestAvailable" uiAccess="true"

          S Offline
          S Offline
          Sternocera
          wrote on last edited by
          #4

          Hi, Doing so doesn't make any discernible difference, Regards, Sterncera

          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