如何使VS2010安装项目中的setup.exe要求管理员特权? [英] How to make the setup.exe from a VS2010 Setup Project ask for Admin Privileges?

查看:231
本文介绍了如何使VS2010安装项目中的setup.exe要求管理员特权?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我想它真的很容易解决...但是,嗯.

I have a problem which I guessed would be really simple to solve... but duh.

我正在用VS2010部署.NET应用程序.我有一个C#Windows窗体项目和一个部署项目.我需要安装程序以管理员权限运行,因为已为所有用户安装了该应用程序,并且已创建注册表项.

I'm deploying a .NET application with VS2010. I have a C# Windows Forms project and a Deployment Project. I need the installer to run with admin privileges because the app is installed for all users and an entry to the registry is made.

启动setup.exe时,不提示我进行特权提升.安装程序将立即启动并建议安装到程序文件(x86),这很好.单击下一步后,安装程序将运行并完成,并显示一条成功消息.这基本上是一个谎言,因为它没有成功安装.相反,它将应用程序exe直接放入C:\.

When starting the setup.exe I'm not prompted for privilege elevation. The installer will just start and suggest to install to Program Files (x86) which is good. After clicking next the installer runs and finished with a success message. Which is basically a lie because it did not successfully install. Instead it puts the apps exe directly to C:\.

如何使安装程序要求管理员特权.还是我必须依靠客户右键单击设置,然后选择非常容易出错"的以管理员身份运行"?

How can I make the installer ask for admin privileges. Or do I have to rely on my customer to right click the setup and select "Run as Admin" which is very error prone?

有关我的设置的说明:

  • 在设置项目的文件系统"视图中,我添加了其他内容",其中包括"project01的主要输出(活动)"和将project01的输出结果(活动)构建到应用程序文件夹".我还添加了快捷方式主要输出"进入用户程序菜单\ CompanyName \ ProgramName".
  • 在注册表视图中,我向HKEY_CLASSES_ROOT添加了一个条目,因为我需要注册一个URL处理程序.

我还修改了设置的设置:我将InstallAllUsers设置为True,因为它应该这样做.

I also modified the setup's settings: I set InstallAllUsers to True because it is supposed to do so.

当我通过双击(或通过从项目的上下文菜单中选择安装")构建并启动setup.exe时,总是会得到相同的结果:安装程序在运行时不要求管理员特权,请询问安装位置(该位置保留默认的C:\ Program Files(x86)\ Company \ ProgramName),然后单击下一步"继续.因此,该exe文件直接放在C:\中,创建的快捷方式当然指向Nirvana.

When I build and start the setup.exe by double clicking (or by selecting Install from the project's context menu) I always get the same result: The installer runs without asking for admin privileges, ask for an install location (which I leave at the default C:\Program Files(x86)\Company\ProgramName) and then procedes after clicking Next. As a result, the exe is put directly in C:\ and the shortcut created of course points into Nirvana.

如果以管理员身份手动运行setup.exe,一切正常.但这不是认真的方法.

If I run the setup.exe manually as Administrator things work fine. But this cannot seriously be the way to go.

那么我如何告诉安装程序始终以管理员身份运行?

So how can I tell the setup to always run as Admin?

推荐答案

我认为这是一个完全有效的问题,是一个实际的问题,并且有实际的解释.

I think this is a perfectly valid question, is a real problem, and has an actual explanation.

我最近遇到了这个问题.就我而言,原因是

I recently ran across this problem. In my case, the cause is that the AlwaysInstallElevated policy was set on the computer through GPO. The policy was set to 1 in the per-machine policy and 0 in the per-user policy. These policies can be manually set to reproduce the effect it has on MSI installers

使用msexec /log install.log /i Deploy.msi,我有一个设置日志,并且其中包含这样的字符串:

Using msexec /log install.log /i Deploy.msi, I had a setup log and there were strings in it like this:

MSI (s) (A4:8C) [13:00:42:885]: Ignoring disallowed property TARGETDIR
MSI (s) (A4:8C) [13:00:42:885]: Ignoring disallowed property VSDNETURLMSG
MSI (s) (A4:8C) [13:00:42:885]: Ignoring disallowed property VSDNETMSG

似乎Visual Studio并未设置 SecureCustomProperties ,并且需要某种后处理.我认为改用 WiX 可能是更好的长期解决方案.

It seems that Visual Studio does not set the SecureCustomProperties in the MSI correctly and post processing of some sort is needed. I think that moving to WiX may be a better long term solution instead.

A

A blog post on MSDN is what I found that helped me find the root cause to this problem.

这篇关于如何使VS2010安装项目中的setup.exe要求管理员特权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆