none
How to make setup project run as admin by default in .net RRS feed

  • Question

  • I have build setup project for my application.

    when I run setup on Windows 7,it requires to run as administrator manually.

    Is there any way to set run as admin property to the shortcut of application

    through setup project so that I dont have to run setup as admin manually.

    It will run as admin by default.

    Thanks in advance.


    AshuP

    • Edited by AshuP Thursday, October 20, 2011 10:26 AM
    • Moved by Min ZhuModerator Monday, October 24, 2011 6:07 AM (From:.NET Platform Architecture Development Discussions)
    Thursday, October 20, 2011 6:36 AM

Answers

  • You can ref my this post:http://social.msdn.microsoft.com/Forums/ar/winformssetup/thread/57d4ee8e-10c5-4a7c-9bdd-82ca3458e83f

    You need to ask for the permission to execute the script, and you can set the MsiBootstrapper property to TRUE as below description.

     

    Typically, Setup.exe (also known as the bootstrapper) does not run as elevated; it runs at the current user's permission level. Therefore, the installation does not prompt for elevation when the final application installation starts. However, note that an .msi file usually prompts the user, whereas Setup.exe does not.

    In the embedded UAC manifest of the bootstrapper, the requestedExecutionLevel node specifies that the installation run as the current user (asInvoker):

    <requestedExecutionLevel level="asInvoker" />

    However, you can elevate the application installation if you have to. For example, modifying Internet Information Services (IIS) settings in a Web Setup project requires administrative privileges, as does installing assemblies to the global assembly cache. The elevation prompt occurs after the prerequisite installations but before the application installation.

    To elevate permissions for an installation, open the project (.vdproj) file. In the project file's MsiBootstrapper section, set the RequiresElevation property to True. This property is not made available through the Visual Studio integrated development environment (IDE). Therefore, you must use the project file. For more information, see RequiresElevation Property.

    And if you need require the permission for the assembly, then you can ref my this tutorial:


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 24, 2011 6:11 AM
    Moderator

All replies

  • Hi AshuP,

     

    'Run As Administrator' is a security behaviour demanded by Operating System such as Windows 7.

    If you wanna run your setup project as administrator by default, please take the following instructions.

    First, right click setup project icon in desktop.

    Second, locate 'Compatibility' tab in Properties window.

    Third, select 'Run this program as an administrator'.

    Fourth, click 'OK' button to apply change.

    Then you can double-click setup project icon to launch it with administative priviledge.

     

    BTW, if you wanna only allow administrator to run your installer (not setup project itself) created by setup project, you can programmatically decide if current logged-on user has administrative priviledge.

     

    Sincerely,

    Robin


    If it solved your problem,Please click "Mark As Answer" on that post and "Mark as Helpful". Lucky everyday!

    Thursday, October 20, 2011 9:40 AM
  • If setup does something which requires admin privledges, there will be a UAC prompt. If the setup project doesn't do anything which requires admin creds it won't prompt. If you need to change your setup project to do something which requires admin credentials.

    Thursday, October 20, 2011 4:20 PM
  • Hi AshuP,

    I have moved this thread to Setup forum where you can get better answers.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 24, 2011 6:08 AM
    Moderator
  • You can ref my this post:http://social.msdn.microsoft.com/Forums/ar/winformssetup/thread/57d4ee8e-10c5-4a7c-9bdd-82ca3458e83f

    You need to ask for the permission to execute the script, and you can set the MsiBootstrapper property to TRUE as below description.

     

    Typically, Setup.exe (also known as the bootstrapper) does not run as elevated; it runs at the current user's permission level. Therefore, the installation does not prompt for elevation when the final application installation starts. However, note that an .msi file usually prompts the user, whereas Setup.exe does not.

    In the embedded UAC manifest of the bootstrapper, the requestedExecutionLevel node specifies that the installation run as the current user (asInvoker):

    <requestedExecutionLevel level="asInvoker" />

    However, you can elevate the application installation if you have to. For example, modifying Internet Information Services (IIS) settings in a Web Setup project requires administrative privileges, as does installing assemblies to the global assembly cache. The elevation prompt occurs after the prerequisite installations but before the application installation.

    To elevate permissions for an installation, open the project (.vdproj) file. In the project file's MsiBootstrapper section, set the RequiresElevation property to True. This property is not made available through the Visual Studio integrated development environment (IDE). Therefore, you must use the project file. For more information, see RequiresElevation Property.

    And if you need require the permission for the assembly, then you can ref my this tutorial:


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 24, 2011 6:11 AM
    Moderator