Program Compatibility Assistant Manifest Not working in Vista32 - winapi

When I run my application "A driver Installer and Uninstaller Application", I am getting a "Program Compatibility Assistant" window once my exe get ended successfully. After going through the SO links and googling I couldnt find a solution to avoid "Program Compatibility Assistant" window in vista 32. I used the below manifest to avoid PCA and it works as expected (am not getting any PCA window in windows 7) but except windows vista 32? What should I do to make this work?
After Using the below manifest for my installer application I am not
getting PCA window in windows 7 but it appears on windows vista
32-bit. How to avoid PCA window in vista32?
Some related questions are:
how-do-i-prevent-programmatically-the-program-compatibility-assistant-in-vista
reasons-for-getting-the-program-compatibility-assistant-dialog
Here's the manifest I used:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="Unins.exe"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<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>
</asmv1:assembly>
The below is the snapshot of PCA window I get...
Update : the root cause I for the PCA window is "My Installer is not creating an entry in Add or Remove Programs". I made my app to make an entry in "Add or remove programs" and am not getting any PCA window. But I dont want to make an entry in Add or Remove Program.
Update 25-09-12: I have an executable say A.exe, which finds
architecture of the OS and depends on the architecture it calls either
A64.exe or A86.exe. In this case do I want to have manifests for all
the exe's ( A.exe, A64.exe, A86.exe )? Right now I have manifest only for A.exe.

In order to opt out of PCA altogether, you will defintely need to include a manifest in all three of your executables.

Related

How to tell a program to run in user mode instead of administrator'

I have build a simple win32, 32 bits software that:
is really simple: one windows, two buttons,
does not need any external exotic library (the ideal is to run under any Windows computer).
This program works fine on xp and 7, but on Vista, the program requires to be running in administrator mode.
How can I tell Vista to run this program "normally"? I tried to edit properties, but nothing things strange. I don't know what requires the program to be launched as admin.
On Vista, this problem comes from the executable name: something_updater.exe.
Some solutions exist to correct the problem, choose one:
With a manifest file:
Add in the program folder some something_updater.exe.manifest file containing:
<?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"
name="something_updater.exe"
type="win32"
/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
At link time:
Add the following option to linker when building the executable:
/MANIFESTUAC:level=asInvoker /MANIFESTUAC:uiAccess=false
Change the program name, with some name not containing update nor setup.

App Manifest Ignored

I am developing an app in Visual Studio 2013 on Windows 7 x64 that requires administrator privileges but it appears my manifest is being ignored:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of all Windows versions that this application is designed to work with.
Windows will automatically select the most compatible environment.-->
<!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->
<!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->
<!-- If your application is designed to work with Windows 8.1, uncomment the following supportedOS node-->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>-->
</application>
</compatibility>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</asmv1:assembly>
To test my theory, I put in some invalid text to see if the parser would crash, but nothing happened. I have tried building as Any CPU, x86, and x64 with the same result. What am I doing wrong?
If you like me removed the manifest and restored it back via source control, your app has likely selected the default-settings-manifest and will ignore all further changes to your custom app.manifest file.
To resolve the problem:
Right click your project
Click properties
Find the Icons and Manifest section
Specify the app.manifest in the drop-down
Save changes

How to add an assembly manifest to a .NET executable?

How can i add an assembly manifest to my .NET executable?
An assembly manifest is is an XML file that is added to a .NET portable executable (PE) with resource type RT_MANIFEST (24).
Assembly manifests are used to declare a number of things about the executable, e.g.:
If i want to disable DPI-scaling because i am a good developer:
<!-- 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>
i can declare that i was designed and tested on Windows 7, and i should continue to depend on any bugs in Windows 7
<!-- We were designed and tested on Windows 7 -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
i can declare that i am a good developer, and don't need file and registry virtualization
<!-- Disable file and registry virtualization -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
i can declare that i depend on a particular version 6 of the Microsoft Common Controls library:
<!-- Dependency on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
i can declare that i depend on a particular version of GDI+:
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.GdiPlus" version="1.0.0.0" processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>
In the olden days, we would create a resource script file (*.rc), e.g.:
wumpa.rc
1 24 AssemblyManifest.xml
add that file to the project, and the compiler would compile the .rc file; including resources in the final executable image.
Except Visual Studio 2010 doesn't seem to have a way to add a resource script file to a project.
How do i add a resource script to a project in Visual Studio 2010?
How do i add an assembly manifest to a project in Visual Studio 2010?
Note: Any solution must work in an environment with source control and multiple developers (e.g. hard-coded paths to probably not installed binaries will break the build and not work).
Bonus Chatter
VS2010/.NET: How to embed a resource in a .NET PE executable?
VS2005: How to embed a manifest in an assembly: let me count the ways... (can't be done)
Update: Michael Fox suggests that the project properties dialog can be used to include an assembly manifest, but he doesn't indicate where:
Update: Things I've tried:
From the project properties screen, select Application. Select radio option Icon and Manifest. Under Manifest leave the default option of Embed manifest with default settings:
Doesn't work because it embeds a manifest with default settings, rather than my settings.
Under Manifest, change the combo option to Create application without a manifest:
Doesn't work because it embeds no manifest
Under Resources select the Resource File radio option:
Doesn't work because you cannot select an assembly manifest (or a resource script that includes an assembly manifest)
Under Resources, select the Resource File radio option, then enter the path to an assembly manifest XML file:
Doesn't work because Visual Studio chokes when presented with an assembly manifest:
Under Resources, select the Resource File radio option, then enter the path to a resource script file:
Doesn't work because Visual Studio chokes when presented with a resource script:
Add the AssemblyManifest.xml to my project, then look for it in the Manifest combo box:
Doesn't work because the Assembly Manifest file isn't listed as an option
i have a dozen other things i can keep screenshotting (add a .rc file to the solution, look for it in the dropdown, select "no manifest" and change the wumpa.rc build action to various things, build the .rc file using a separate resource compiler, either manually, or a pre-build/msbuild step, and select that .res file as my resource). i'll stop adding extra bulk to my question and hope for an answer.
If you want to add custom information to your application's manifest, you can follow these steps:
Right-click on the project in the Solution Explorer.
Click "Add New Item".
Select "Application Manifest File".
This adds a file named app.manifest to your project, which you can open and modify as desired.
Similar steps, with screenshots, lifted from Declaring Managed Applications As DPI-Aware on MSDN:
In the Solution Explorer, right-click on your project, point to Add, and then click New Item.
In the Add New Item dialog box, select Application Manifest File, and then click Add. The app.manifest file appears.
Copy and paste the following text into the app.manifest file and then save.
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<!-- Disable file and registry virtualization. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<!-- <requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
-->
</requestedPrivileges>
</security>
</trustInfo>
<!-- 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>
<!-- Declare that we were designed to work with Windows Vista and Windows 7-->
<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>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</asmv1:assembly>
In the Solution Explorer, right-click on the project, and then click Properties to verify that the app.manifest is used.
Your application is now manifested as required to be "designed for Windows", and is
disables file and registry virtualization
disables DWM scaling of applications
announces that you were designed and tested on Windows 7 and Windows Vista
takes a dependency on Common Controls library version 6 (enabling the use of visual styles by the common controls)
I have Visual Studio 2010 Professional with Service Pack 1 installed. I am running on Windows 7 Ultimate 64-bit. If I follow these instructions, the project properties shows "Embed manifest with default settings" in the resources block, and also the option is disabled! When I build, the manifest does not get embedded into the DLL as I verified by opening the DLL in resource view.
However, if I :
Locate the added app.manifest file in the Solution Explorer
Right-click and choose Properties
Change the Build Action property from "None" to "Embedded Resource"
Rebuild
The manifest file is embedded properly, which I can verify by loading the DLL into the resource view. The Manifest setting in the Application properties still shows as "Embed manifest with default settings" and is still disabled.
In Visual Studio 2008, this can be done in the Project Properties window. I'm almost positive it is the same in 2010. Right click on your project, select properties, and in the application tab you can select a manifest. You have to add it to your project first, but you can do that easily by adding an existing file.

Windows 7 requires UAC elevation for VB6 application (Vista did not)

I have an old VB6 application which should run on Windows 7 (with UAV set to the default level, 3 of 4 IMHO). It has the functionality to update itself, and Windows 7 is now complaining that it would modify the computer (At least windows 7 is right here).
I was able to run it in Vista with some kind of manifest file, but this does not seem to work anymore (which is the intended behaviour if I think of it).
The manifest file is this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.1.0.24" processorArchitecture="X86" name="IKOfficeAppStarter" type="win32"/>
<description>IKOffice Starter</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="true"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
The manifest can be found near the exe "IKOffice Starter.exe" and is called "IKOffice Starter.exe.manifest", which should be okey.
Currently the Shield Icon has gone from my .exe, but when try to start the software, i get the message "Der angeforderte Vorgang erfordert höhere Rechte", or translated to english "the requested operation requires elevation".
What can I do to stop windows to bug me anymore, so I can install this application on our clients computers. Hey, I already told Windows to run it as Invoker, so why is it still complaining?
Where does that error message come from? Windows or your VB6 app? Could the VB6 app be saying "hey, you're running me as invoker but I need to be run elevated?" After all, VS2008 does that. Or do you think Windows is saying that to you?
Also I doubt you need uiAccess=true and since manifests tend to get copied from project to project, make it false.

Delphi app manifest file problems under WinXP and Win7

My last question "List service and services status under Win-7" made me start working on a solution that gives my app the admin privileges under Windows Vista onward based on a .manifest file.
I was not sure about continue the previous question with this matter since they are not the same so here is another question:
My app now works fine under Win 7 whether or not I run it "as admin" because of the manifest file.
My manifest file is as follow:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.6.0.5" processorArchitecture="X86" name="ServiceMonitorPro" type="win32"/>
<description publisher="Powershield Ltd" product="Powershield Service Monitor">Powershield Service Monitor</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
When the application runs on windows 7 or Vista, the UAC comes with a dialog like this:
alt text http://www.freeimagehosting.net/uploads/39787fd3dd.jpg
How can I replace the "unknow" publisher?
The other and bigest problem is, even thou the app runs with no problem under Win7 or Vista, under WinXP it is now crashing with the message:
"This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem."
Another thing I would like to add: If
I add reference (uses clause) to XPMan
the app works fine on WinXP but then
it my .manifest file makes no
diference under Vista or Win7.
I have to thank everyone that, with comments or answers point me to keep digging... :)
I went to search for the file WindowsXP.res.
The content of that file is:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="DelphiApplication"
version="1.0.0.0"
processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"/>
</dependentAssembly>
</dependency>
</assembly>
The solution: I have mixed my .manifest file with the WindowsXP.Res xml one adding the dependency section.
If anyone know why its now working, I would be glad to hear about - but this was the solution here - tested so far in a couple of virtual machines, on my computer and a couple of others... working :)
You need to sign your code with a code signing certificate. There should be lots of examples here. I have re-tagged your question with "code-signing", and you can also look for "certificate".
I use Comodo certs myself, and sign them with the awesome, wonderful, Visual Build Pro v6, which is an advertiser here on SO.
You can indicate compatibility with various versions of Windows in your manifest as well. I know that there are entries for compatibility with Vista and Win7; not sure about XP.
Info about the manifest compatibility section is available at MSDN. This may help, also - from the linked page:
<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>
On newer versions of Delphi (7 and above I think) you also need to also be sure to uncheck the "Use Runtime Themes" option in your project options dialog, otherwise Delphi will automatically link in its own default manifest file (that's how it enables the "theme support") and you will get a runtime error about the application's configuration being incorrect, because there will be conflicting entries.
Here's a complete manifest file for a Delphi2007 app which needs to run in adminstrator mode in Windows 7, and also includes the "dependency" section to enable runtime theme support:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="CodeGear RAD Studio"
version="11.0.2902.10471"
processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

Resources