gpt4 book ai didi

windows - 寻找有关在 Windows 7 上安装应用程序的 "right"方式的文档

转载 作者:行者123 更新时间:2023-12-02 08:58:40 25 4
gpt4 key购买 nike

我正在使用一些旧应用程序(10-15 年),并试图找到有关在 Windows 7 上安装和运行它们(以及任何用户应用程序)的“正确”方法的指导,而无需完整的管理员权限.

换句话说,可执行/只读文件应该放在哪里,用户数据/读写文件应该放在哪里,注册表项应该放在哪里,以避免UAC和Windows 7文件/注册表虚拟化在这两个过程中出现问题安装和运行时。

我似乎记得几年前有一篇关于这个主题的微软白皮书,但现在找不到任何相关信息。我找到了有关用户方面的信息(如何通过兼容性调整让旧版应用程序在 Windows 7 上运行),但没有找到有关开发人员方面的信息(如何创建/安装应用程序以在 Windows 7 上正常运行)。

任何指向此类信息的指针将不胜感激。谢谢。

马克

最佳答案

您正在考虑 Windows Logo Requirements .

  1. Install to the correct folders by default

Users should have a consistent and secure experience with the default installation location of files, while maintaining the option to install an application to the location they choose. It is also necessary to store application data in the correct location to allow several people to use the same computer without corrupting or overwriting each other's data and settings.

Windows provides specific locations in the file system to store programs and software components, shared application data, and application data specific to a user:

  • Applications should be installed to the Program Files[16] folder by default. User data or application data must never be stored in this location because of the security permissions configured for this folder

[16] %ProgramFiles% for native 32-bit and 64-bit applications, and %ProgramFiles(x86)% for 32-bit applications running on x64 respectively

  • All application data that must be shared among users on the computer should be stored within ProgramData

  • All application data exclusive to a specific user and not to be shared with other users of the computer must be stored in Users\\AppData

  • Never write directly to the "Windows" directory and or subdirectories. Use the correct methods for installing files, such as fonts or drivers

  • In “per-machine” installations, user data must be written at first run and not during the installation. This is because there is no correct user location to store data at time of installation. Attempts by an application to modify default association behaviors at a machine level after installation will be unsuccessful. Instead, defaults must be claimed on a per-user level, which prevents multiple users from overwriting each other's defaults.

接下来的事实是,您不应该写入任何需要管理权限的位置。

Note: You can test all of this on a Windows 2000 or Windows XP simply by (as Windows 2000 Logo Requirements required) running as a standard user.

由于大多数应用程序忽略了 Logo 要求,并且在使用标准用户权限运行时会失败,因此 Windows Vista 提供了通过虚拟化对 protected 位置的写入来使这些有缺陷的应用程序保持跛行的功能,而不是让它们失败。

您可以通过将您的应用程序显示为RunAs Invoker来选择退出此兼容黑客:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
...
<!-- Disable file and registry virtualization -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
...
</assembly>

Logo 指南讨论了 UAC 和写入某些位置的虚拟化:

  1. Follow User Account Control (UAC) Guidelines

Some Windows applications run in the security context of an administrator account, and many require excessive user rights and Windows privileges. Controlling access to resources enables users to be in control of their systems against unwanted 20 changes. The most important rule for controlling access to resources is to provide the least amount of access “standard user context” required for a user to perform his or her necessary tasks. Following UAC guidelines provides applications with the necessary permissions when needed, without leaving the system constantly exposed to security risks.

Most applications do not require administrator privileges at run time, and should be just fine running as a standard-user. Windows applications must have a manifest 21 (embedded or external 22 ) that defines their execution levels and tells the OS what privileges the application requires in order to run.

  • For example,

  • The main process of the application must be run as a standard user (asInvoker). Any administrative features must be moved into a separate process that runs with administrative privileges.

  • A waiver is required for applications that run their main process 23 with elevated privileges (requireAdministrator or highestAvailable)

Waivers will be considered for the following scenarios:

  • Administrative or system tools with execution level set to highestAvailable, and or requireAdministrator

Or

  • Only Accessibility or UI automation framework application setting the uiAccess 24 flag to true to bypass the user interface privilege isolation (UIPI)

然后是高 dpi。十年来的 Windows Logo 要求要求应用程序能够对高(即非 96dpi)显示器做出适当的响应。由于如果用户确实使用“大字体”,大多数应用程序都会严重崩溃,因此微软放弃了,并且像文件系统的虚拟化一样,他们也虚拟化了 dpi 设置。除非应用程序选择退出兼容性破解:Windows 会欺骗您并告诉您您的分辨率是 96dpi。

只有正确编写应用程序后,才应在应用程序 list 中添加一个条目以禁用高 dpi 缩放:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
...
<!-- We are high-dpi aware on Windows Vista -->
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
...
</assembly>

无论如何,一切都在那里,Windows 7 Client Software Logo Program .

<小时/>

注意:如果您在 15 年前(1995 年)编写 Windows 应用程序,我假设您编写的目的是:

  • Windows 3.1,或
  • Windows 95

而不是:

  • Windows NT 3.1
  • Windows NT 3.5
  • Windows NT 4
  • Windows 2000
  • Windows XP

值得注意的是,Windows NT 被设计为一个安全操作系统。你不可以随意做任何你想做的事。这与以下内容有根本区别:

  • Windows 1
  • Windows 2
  • Windows 3
  • Windows 3.1
  • Windows 95
  • Windows 98
  • Windows Me

没有安全保障。

写入 Windows 和 Program Files 文件夹需要管理员权限。这是因为通常只有管理员才应该安装应用程序。但普通用户无法修改或损坏已安装的程序 - 或 Windows 本身的安装,例如:

关于windows - 寻找有关在 Windows 7 上安装应用程序的 "right"方式的文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5622681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com