最简单的方法就是文件名中包含 update setup install字样
此办法来自MSDN
http://social.msdn.microsoft.com/Forums/en-US/windowscompatibility/thread/1b316a7f-852e-4a71-89d3-090e45990f98
Installer Detection Technology
http://technet.microsoft.com/en-us/library/cc709628%28WS.10%29.aspx
Installation programs are applications designed to deploy software, and most write to system directories and registry keys. These protected system locations are typically writeable only by an administrator user, which means that standard users do not have sufficient access to install programs. Windows Vista heuristically detects installation programs and requests administrator credentials or approval from the administrator user in order to run with access privileges. Windows Vista also heuristically detects updater and uninstallation programs. Note that a design goal of UAC is to prevent installations from being executed without the user's knowledge and consent since they write to protected areas of the file system and registry.
Installer Detection only applies to: 32 bit executables(仅限于32位系统) Applications without a requestedExecutionLevel Interactive processes running as a Standard User with UAC enabled(开启UAC并且是普通用户)
Before a 32 bit process is created, the following attributes are checked to determine whether it is an installer: Filename includes keywords like "install," "setup," "update," etc. () (文件名包含有 install setup update 任何一个) Keywords in the following Versioning Resource fields: Vendor, Company Name, Product Name, File Description, Original Filename,Internal Name, and Export Name Keywords in the side-by-side application manifest embedded in the executable Keywords in specific StringTable entries linked in the executable Key attributes in the resource file data linked in the executable Targeted sequences of bytes within the executable
上面的意思是,只要文件名包含有setup install update ,系统就会认为你这是一个需要高权限的程序,然后提示用户是否放行 蓝色文字部分就是下面图中aardioIDE的这个部分,任何一个地方包含有上面3个词语,都会同上
附:aardio新版本已支持自定义Manifest了。
首先生成一次EXE文件,可以看到工程目录下自动生成了默认的 /.build/Manifest.xml
可以用记事本打开编辑此文件后在最后一行“</assembly>”之前添加如下代码保存再生成EXE即可。
- <!-- Identify the application security requirements. -->
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
- <security>
- <requestedPrivileges>
- <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
- </requestedPrivileges>
- </security>
- </trustInfo>
复制代码 参考:检查是否是以管理员方式运行程序 |