使用 C# 在没有 UAC 的 Windows 7 中安装应用程序

发布于 2024-09-15 13:58:55 字数 92 浏览 5 评论 0原文

当我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

丢了幸福的猪 2024-09-22 13:58:55

UAC 提示符显示的原因有很多,其中没有一个是“exe 内的代码调用函数 X 或尝试写入位置 Y”。其中包括:

  • 名称包含安装程序、补丁、更新等(例如 setup21.exe),并且没有
  • 您嵌入的清单要求 requireAdministrator。您可能是在 Visual Studio 中故意这样做的。
  • 在要求 requireAdministrator 的同一文件夹中,有一个外部清单(对于 NewApp.exe,它将是 NewApp.exe.manifest)。你也是故意这么做的。
  • 您右键单击了该 exe,并在“属性兼容性”上选择提升它,或者以 XPSP2 运行,对于 7,这也会提升
  • 您公司中的某个人已应用的组策略,该安装应用程序应以提升(不太可能)的
  • 方式运行您一旦运行它,就会收到来自 Windows 的对话框,提示“这可能无法正常工作”,并同意使用“推荐设置”重试。

这些看起来有可能吗?如果是这样,请更正它们并查看 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:

  • the name contains setup, patch, update etc (eg setup21.exe) and there is no manifest
  • you embedded a manifest that asks for requireAdministrator. You would have done this on purpose in Visual Studio.
  • there is an external manifest (for NewApp.exe it would be NewApp.exe.manifest) in the same folder that asks for requireAdministrator. You would have done this on purpose too.
  • you have right-clicked the exe, and on the Properties Compatibility you have chosen to elevate it, or to run as XPSP2 which for 7 also elevates
  • someone in your company has applied a Group Policy that this installation app should run elevated (unlikely)
  • you once ran it, got a dialog from Windows saying "that may not have worked right" and agreed to try again with "recommended settings"

Do any of these seem likely? If so, correct them and see if the UAC prompt goes away.

够运 2024-09-22 13:58:55

单一包创作 链接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.

遗失的美好 2024-09-22 13:58:55

如果您想安装没有 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.

懒的傷心 2024-09-22 13:58:55

如果您希望在不触发 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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文