收藏自:http://blogs.msdn.com/astebner/archive/2007/05/17/2705372.aspx
+http://www.debugman.com/simple/index.php?t325.html
How to prevent the Program Compatibility Assistant from appearing on Windows Vista
While researching the root cause of the issue that can cause a Windows XP SP2 block dialog to appear when trying to install the .NET Framework 3.5 beta 1 on Windows Vista (described in more detail in this blog post ), I learned some useful information about the Program Compatibility Assistant (PCA) that I wanted to summarize here.
What kinds of applications are affected by the Program Compatibility Assistant?
The Program Compatibility Assistant monitors setup applications that it detects are not Windows Vista-aware. The PCA uses a list of well-known names such as setup.exe, install.exe, etc to try to decide whether or not an application is a setup. The PCA treats all setup applications that do not have an embedded manifest that specifies a requested execution level (asInvoker, highestAvailable or requireAdministrator).
In the case of the .NET Framework 3.5 beta 1, the setup package did not include an embedded manifest specifying a requested execution level, and it was named dotnetfx35setup.exe, which triggers the Windows Vista legacy setup application detection logic.
When does the Program Compatibility Assistant appear?
Once the Program Compatibility Assistant identifies a non-Windows Vista-aware setup application, it will monitor the Programs and Features control panel (previously known as Add/Remove Programs). If an entry is not created or removed from the Programs and Features control panel, then the PCA treats the process as a failed setup and displays a dialog after the setup process exits that asks if the user wants to attempt to re-install using recommended settings. In this case, using recommended settings will cause Windows Vista to re-run the setup using Windows XP SP2 compatibility mode.
In the case of the .NET Framework 3.5 beta 1, because the setup application is treated as a non-Windows Vista-aware setup, whenever it returns without creating or removing a Programs and Features control panel entry, the PCA dialog will appear (even if you simply launch setup and cancel on the End User License Agreement page).
How can I opt out of the Program Compatibility Assistant for my setup?
In order to prevent the Program Compatibility Assistant from appearing, you must include an embedded manifest that specifies a requested execution level for your setup executable. If you wrap the setup executable in a self-extracting package, you must also include an embedded manifest in the self-extracting package too. Once you do this, Windows Vista will treat your setup as Windows Vista-aware, and it will no longer show the PCA dialog when setup exits after a failure or cancellation.
Where can I find more detailed documentation?
For more detailed information about the Program Compatibility Assistant, I encourage you to check out the following resources:
- The Windows Vista Developer Story: Application Compatibility Cookbook - http://www.microsoft.com/indonesia/msdn/appcomp.aspx
- Windows Vista Application Development Requirements for User Account Control Compatibility - http://www.microsoft.com/downloads/details.aspx?FamilyID=BA73B169-A648-49AF-BC5E-A2EEBB74C16B&displaylang=en
# re: How to prevent the Program Compatibility Assistant from appearing on Windows Vista
Does PCA's detection of Vista-Awareness depend on whether or not UAC is ON/OFF?
I ask this because I have a setup executable that indeed has a manifest specifying 'requireAdministrator'. When canceling out of my setup, the PCA dialog will appear only when UAC is off. And my manifest should be well-formed, since it invokes a UAC dialog upon launch when UAC is on.
Any tips as to how to prevent the PCA dialog from showing up with UAC off?
# re: How to prevent the Program Compatibility Assistant from appearing on Windows Vista
Hi Symkt - I haven't heard of this issue until now. Would it be possible for you to zip and send me your setup.exe so I could take a look at this in more detail? You can send it to Aaron.Stebner (at) microsoft (dot) com.
# re: How to prevent the Program Compatibility Assistant from appearing on Windows Vista
Hi, I'm trying to downgrade vista to XP pro sp2, but whenever i click install in the windows xp install menu, that damn program compatibility assistant pops and disallows it. Could you help me out?
# re: How to prevent the Program Compatibility Assistant from appearing on Windows Vista
Hi Bp9129 - I haven't tried to install Windows XP from within Windows Vista before, so I don't know for sure if that is expected to work. Can you try to boot from your Windows XP CD and install from there instead of running it from within Windows Vista?
# What to do if VS 2008 or .NET Framework 3.5 beta 2 asks for Windows XP SP2 on Windows Vista
I previously posted a description of a bug in VS 2008 beta 1 and .NET Framework 3.5 beta 1 setup that
# What to do if VS 2008 or .NET Framework 3.5 beta 2 asks for Windows XP SP2 on Windows Vista
I previously posted a description of a bug in VS 2008 beta 1 and .NET Framework 3.5 beta 1 setup that
# Narrowing down odd behavior in the Program Compatibility Assistant on Windows Vista
Recently, a fellow Microsoft employee found this blog post that I wrote a while back, and he contacted
# MSDN Blog Postings » Narrowing down odd behavior in the Program Compatibility Assistant on Windows Vista
PingBack from http://msdnrss.thecoderblogs.com/2007/10/16/narrowing-down-odd-behavior-in-the-program-compatibility-assistant-on-windows-vista/
VC編譯出來的應用程序在vista下運行,有可能因爲權限問題,不能成功運行。
用以下辦法,給應用程序添加一個manifest文件,程序運行時系統就會跳出UAC對話框,獲得管理權限。
1.打開應用程序的源代碼工程
2.添加一個“custom”資源,"resource type"填24,把資源ID改爲1,然後把以下內容複製到資源內容中保存
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="mulitray.exe.manifest"
type="win32"
/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
3.重新編譯應用程序,此時會發現,廣用程序的圖標在vista下會多出一個小盾標誌。