VS2010 Setup Project - Run As Administrator

只谈情不闲聊 提交于 2019-12-03 11:59:43

As pointed out by Frank, the Visual Studio setup project's behavior is documented at Microsoft's web site:

Visual Studio Installer Deployment

In other words, the setup.exe produced by VS008 and VS2010 will always be run without prompting for privilege elevation (unless you explicitly run it using the 'Run As Administrator' context menu option). It in turns will run each prerequisite component as well as the main MSI installer as separate processes and prompts for privilege elevation for any of them that needs it. This means that there may be multiple prompts for elevations.

However, for some reasons this does not always work. In my case, the elevation prompt for the .NET Framework prerequisite does not come up at all when I run setup.exe. But if I run the prerequisite installer directly, the prompt will come up. This means that the problem lies not with the prerequisite component, but with either setup.exe or with Windows itself.

The solution (or workaround)? According to Microsoft in the link above, we can force setup.exe to launch each prerequisite component and the main MSI to run with elevation prompts. To do this, we need to manually edit the setup project file (.vdproj) and change the following RequiresElevation value to TRUE, as shown below:

"MsiBootstrapper"
{
    "LangId" = "3:1033"
    "RequiresElevation" = "11:TRUE"
}

This is not the ideal solution, but it is close enough to my original requirement, so I'm satisfied with this solution.

If you want to Run MSI in admin mode here is the way, 1) Open your Setup Project, View->Launch Conditions.

2) Right click on Launch Conditions, and add a new Condition in your Launch Conditions.

3) Right click the Condition, choose Properties Window.

4) Set Condition to

AdminUser

. 5) Build and install.

DeanOC

I think that your problem is to do with the name of the installer. This link

How do I avoid UAC when my EXE file name contains the word "update"?

says that if the name has Update or Setup in it, then UAC will kick in.

Can you rename your installer to something else?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!