使用 C# 在没有 UAC 的 Windows 7 中安装应用程序
当我在 Windows 7 中安装 C# 应用程序时,UAC 始终显示。我没有以管理员身份登录,但我希望在没有 UAC 的情况下安装我的应用程序。 你能给我一些方法吗?
When I install my C# app in windows 7, UAC always shows. I'm not logged in as Administrator but I want my application to be installed without the UAC.
Can you give me ways on how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
UAC 提示符显示的原因有很多,其中没有一个是“exe 内的代码调用函数 X 或尝试写入位置 Y”。其中包括:
这些看起来有可能吗?如果是这样,请更正它们并查看 UAC 提示是否消失。
The UAC prompt shows for any number of reasons, none of which is "the code inside the exe calls function X or tries to write to place Y." These include:
Do any of these seem likely? If so, correct them and see if the UAC prompt goes away.
单一包创作 链接text
您需要使用 Windows 安装程序 / Windows Installer XML 使此安装按照您请求的方式运行。
Single Package Authoring link text
You'll want to use Windows Installer / Windows Installer XML to make this install behave the way you request.
如果您想安装没有 UAC 的应用程序,那么您只能触摸当前登录用户可以写入的文件夹。 Google Chrome 就是这样做的——它将整个应用程序安装到用户的本地应用程序数据文件夹中。
这是非常不标准的,我认为微软应该禁止从这个位置运行代码,但它是一个需要管理员/UAC 访问权限来安装应用程序的可行解决方案。
顺便说一句,Google Chrome 最近提供了一个传统的安装程序,因此一个用户可以安装它以供计算机上的所有用户使用。
If you want to install an app without UAC then you can only touch folders that the currently logged in user can write to. Google Chrome does this--it installs the entire application to the user's local application data folder.
It's very non-standard and I would argue MS should prohibit running code from this location, but it's a working solution to requiring administrator/UAC access to install applications.
Incidentally, Google Chrome more recently made a traditional installer available so one user can install it to be used by all users on the computer.
如果您希望在不触发 UAC 的情况下安装应用程序,请安装到 %APPDATA%(而不是安装到 %ProgramFiles%)并仅写入注册表中的 HKCU 配置单元(即不要尝试写信给 HKLM、HKCR 等)
If you want your application to be installed without triggering the UAC, install to %APPDATA% (instead of installing to %ProgramFiles%) and write to the HKCU hive only in the registry (i.e. don't try to write to HKLM, HKCR, etc.)