This is the nineteenth in a series of notes about UAC in MSI. Per the earlier caveat, these are just my notes and not an official position from the Windows Installer team. The previous entries
This entry continues a section specifically focused on Question and Answers that often come up in the UAC in MSI dialogs. For this topic, the question is: how do I add shield to my advertised shortcut?
My application is advertised. How do I get the shield on the advertised shortcut?
If you are a developer of an Administrator-Only Application, you will need to manifest your application itself to get the credential prompt appropriate to the users’ rights. If you install supports advertised shortcuts you will also need to manifest your icon. Here's a quick walkthrough for what you need to add a Shield to your shortcut.
Base Generation of an Icon EXE for your Advertise Shortcut
Here's how one generates the icon only exe for advertised shortcut
//
// base resource script.
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
// Icon
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "icon.ico"
// Used by icon.rc
#define IDI_ICON1 101
c:\icon>rc icon.rc
c:\icon>link icon.res /noentry /machine:x86 /dll /out:icon.exe
c:\icon>dir /o:d
1,078 icon.ico
421 icon.rc
71 resource.h
1,912 icon.RES
2,560 icon.exe
Shortcut
Directory_
Name
Component_
Target
Arguments
Description
Hotkey
Icon_
IconIndex
ShowCmd
WkDir
AdministratorTool
AdminToolsDirectory
Admin.exe
AdminTools
icon.exe
Data
<?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="Icon"
type="win32"/>
<description>Description of your application</description>
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
// Tweaked resource script.
// Add Shield - per http://msdn.microsoft.com/library/en-us/dnlong/html/AccProtVista.asp
#define MANIFEST_RESOURCE_ID 1
MANIFEST_RESOURCE_ID RT_MANIFEST "icon.exe.manifest"
600 icon.rc
657 icon.exe.manifest
1,916 icon.RES
3,072 icon.exe
Why the second manifest anyway?
The way the Windows Installer enables advertised shortcuts is by pointing Windows the shortcut icon to a cached EXE and putting a Darwin Descriptor in the target path. Dividing a package this way enables the CreateShortcuts action in the AdvtExecuteSequence table to populate the Advertised shortcut. When the user clicks on the shortcut, the Darwin Descriptor is decoded by the Windows shell into parameters that are passed to the Windows Installer.
Windows Installer will evaluate if the thing pointed as is present locally and install it if it's not. Due to the caching of credentials with Windows Installer 4.0 support for User Account Control, the Windows Installer will not prompt for credentials. The good news is that even with the dual manifesting one will get just one credential prompt at the launch of the target EXE.