Tech Off Thread

5 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Elevate application on certain action in C#

Back to Forum: Tech Off
  • User profile image
    GurliGebis

    Is it possible for a problem to call a function, to get the UAC prompt up, so a certain function in my program i run as the Administrator.
    (Developing an application that downloads an MSI file over the network, and needs to run it as the Administrator, to get the application updated)

    And I do that?

  • User profile image
    T-Shooter

    No, you can't partially elevate an application. Only processes can be elevated.

    Thus, you need to ShellExecute another program - e.g. a console application created by you - using the "runas" verb to prompt the user for elevation.

  • User profile image
    Yggdrasil

    T-Shooter wrote:
    

    No, you can't partially elevate an application. Only processes can be elevated.

    Thus, you need to ShellExecute another program - e.g. a console application created by you - using the "runas" verb to prompt the user for elevation.



    Well, technically you can ask the user for a username and password and impersonate that account from your code, but this would require having the actual password, and requesting that from a user is mighty suspicious, and will probably trigger ANOTHER password check from UAC afterwards.

  • User profile image
    GurliGebis

    If I get the application to launch an MSI, wont vista ask about UAC then?

  • User profile image
    Sven Groot

    It should. If not right away, then at least when installation begins.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.