在 Windows Vista+ 系统下,若 EXE 文件名中包含有「install」、「update」或「setup」等字样,可能出现如下问题:
| | setup.exe |
|
简而言之,上述现象发生的原因是 Windows Vista+ 系统的「安装程序检测」机制认为文件名中包含「install」、「update」或「setup」等字样,且没有在 Manifest 文件中显式指定 requestedExecutionLevel 的 32 位可执行程序是安装包,会主动为安装包弹出 UAC 提权申请,而「程序兼容性助手」会监控安装包的执行情况,如果它没有在「添加或删除程序」中创建一个条目,那「程序兼容性助手」会认为该安装包没有成功完成,在安装包结束后即弹出「程序兼容性助手」提示用户该程序可能安装不正确。
MSDN 关于「程序兼容性助手」的相关问答:
原文链接:Application Compatibility: Program Compatibility Assistant (PCA)
MSDN 关于「安装程序检测」的相关介绍:
Installer Detection only applies to:
Before a 32 bit process is created, the following attributes are checked to determine whether it is an installer:
原文链接:New UAC Technologies for Windows Vista.aspx)
另外,微软的一个 PPT 介绍了「安装程序检测」和它可能产生的误判,以及解决的办法,给出的方案是内嵌 Manifest 或者外置一个名为「MyApp.exe.manifest」的文件:
参考:
问题 1:
如下三项任选其一:
一、给程序改个名字,不要包含「install」、「update」和「setup」字样。
二、为可执行文件添加类似如下的 Manifest 文件,指定程序兼容 Win7 与 Vista(或更高版本的当前系统)。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>
三、程序运行时在注册表项 HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Persisted
下写入以可执行文件全路径为名,值为 REG_DWORD 类型的 1 的项。
问题 2 和 3:
这是 Windows Vista+ 系统对「安装包」的「特殊待遇」,如果你正在做安装包,那你应该不在乎这些;如果你正在做的不是「安装包」,那么将程序改名吧!去掉 install,去掉 update,去掉 setup,世界从此清净了。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有