CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1

    Switching application into administrator mode

    Does anyone know how or if you can have an application switch into admistrator mode to run a particular section of code without having to launch it as a process that requests adminstrative privelages. This particular section, I want them to have to be an administrator to run, but I do not want to have to seperate it from the whole and then launch it as a seperate process.
    --------------------------------------------------------------------------------------------------------------------------
    Disclaimer - Most likely any code I have posted as an answer was most likely written free hand and may have some minor compile errors, and is merely intended to give you the idea.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Switching application into administrator mode

    I think the best solution, IMHO, would be to run the whole application with full admin rights, then there isn't ever a need to switch to admin mode; which I don't think is possible.

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Switching application into administrator mode

    You should understand how to write a UAC compliant application.

    http://download.microsoft.com/downlo...pplication.ppt

  4. #4

    Re: Switching application into administrator mode

    I dont want to "make" a new one, I want to do as little as possible to make an old one compliant, there is quite a large differance.

    At any rate the slides did answer the question, there is no way to elevate a running process, so the only way is to seperate the code into a new EXE and launch it as a seperate process, since I still want to force the user to have admin privelages to run this particular section.
    Last edited by matthewsanford@gmail.com; July 19th, 2010 at 01:21 PM.
    --------------------------------------------------------------------------------------------------------------------------
    Disclaimer - Most likely any code I have posted as an answer was most likely written free hand and may have some minor compile errors, and is merely intended to give you the idea.

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Switching application into administrator mode

    Quote Originally Posted by matthewsanford@gmail.com View Post
    I dont want to "make" a new one, I want to do as little as possible to make an old one compliant, there is quite a large differance.
    I'm sorry, I didn't mean to imply you need to make a new application. You can make your application UAC compliant by reading the link I supplied and make the changes to your current app.

  6. #6
    Join Date
    Jul 2010
    Posts
    82

    Re: Switching application into administrator mode

    There is no way to switch it into admin mode within the process. Its from another process, so as another exe, and then may be you can use params to "switch back" to your old compliant one.

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Switching application into administrator mode

    All you need to do ( firstly ) is to create a manifest file for your application, as explained in slide 24, then take it from there. No need to create a new app.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured