How to programmatically disable Program Compatibility Assistant in Windows 7 and Vista for a native C++ application?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 04:32:47

问题


I have a custom installer application built with C++/ATL. The application's target platform is XP3, VS solution consists of static lib and exe projects. The application always to be started elevated, i.e. as Administrator

When I run it from Visual Studio (VS itself is started as Administrator) then everything is fine, PCA is never shown. When I run it on the same machine from Explorer then PCA is also never shown.

However, when I run it on a fresh Windows 7 machine then PCA is always shown, no matter if I start it from elevated or non-elevated Explorer.

Manifest-related section in project properties is set like this: http://screencast.com/t/70GOcbf243

What do I do in order to get rid of PCA on the second machine? Thank you!


回答1:


I think you should rename your application. There are some hard-coded names which forces the PCA... like:

  • Productname contains “instal” or “setup” or “update
  • Companyname contains “instal” or “setup” or “update
  • Internalname contains “instal” and app is not named “TrustedInstaller.exe”
  • Originalfilename contains “instal” and app is not named “TrustedInstaller.exe”
  • Filedescription contains “instal” and app is not named “TrustedInstaller.exe”
  • Filename contains “instal” and is not named “TrustedInstaller.exe”
  • Exportname contains “setup.exe” or “install.exe” or “stub32″ or “stub32.exe” or “signstub.exe”
  • Filename contains “patch” or “setup” or “uninst” or “update” or “lhaca*.exe”
  • Filedescription contains “instal” or “setup” or “update” or “uninst
  • Originalfilename contains “setup” or “update
  • Originalfilename contains “setup” or “update

See also: Custom installer without warning dialog… (TrustedInstaller.exe)

As an alternativ, you can add the OS compatibility section in your application manifest to prevent the PCA. Ad the following to your application manifest:

<?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>

For more info, see also Application Manifest



来源:https://stackoverflow.com/questions/17660404/how-to-programmatically-disable-program-compatibility-assistant-in-windows-7-and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!