Wix - Setting Compatibility Mode on shortcut for all users - wix

I have a msi that has its InstallScope set to "perMachine" and it creates a shortcut which is available to all the users:
<Directory Id="ProgramMenuFolder">
<Directory Id="CompanyShortcutsDir" Name="My Company" />
</Directory>
<Component Id="CMP_MainExeShortcut"
Directory="CompanyShortcutsDir"
Guid="{B857CD9E-XXXX-YYYY-F2090C50C985}">
<Shortcut Id="MyExeStartShortcut"
Name="My Product"
Description="$(var.WIX_PRODNAME)"
Target="[APPLICATIONFOLDER]MyApp.exe"
WorkingDirectory="APPLICATIONFOLDER"
Icon="my.ico" />
<RemoveFolder Id="RemoveCompanyShortcutsDir"
On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\MyCompany"
Name="MainExeShortcut"
Type="integer"
Value="1"
KeyPath="yes" />
</Component>
and the shortcut does indeed appear for all the users - so far so good !!
But I also have this fragment of code:
<Component Id="CMP_MainExeShortcutCompat"
Directory="CompanyShortcutsDir"
Guid="{C748B7C6-XXXX-YYYY-7CB1823774DC}">
<RegistryValue Root="HKMU"
Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
Name="[APPLICATIONFOLDER]MyApp.exe"
Type="string"
Value="~ WIN7RTM"
KeyPath="yes"/>
</Component>
who's purpose is to set the "Compatibility Mode" on the shortcut to be "Windows 7" - but this only happens for the user that installed our product, it doesn't get set on the shortcut for the other users who are likely to login to the PC.
Does anyone know how I can set this flag on the shortcut for all the users ?
Many Thanks,
Chris.

Related

Wix recreate deleted shortcut when reinstalling

I'm learning about shortcuts in Wix and have managed to create shortcuts on the desktop.
If I delete the shortcut and then run the installer again I would like the shortcut to be created again.
How can this behavior be achieved with Wix?
I have created shortcuts both with
<File Id="TestX.exe" Name="TestX.exe" Source="$(var.TestX_TargetDir)TestX.exe">
<Shortcut Id="desktopIcon" Directory="DesktopFolder" Name="TestX" WorkingDirectory='INSTALLFOLDER' Icon="IconTestX.exe" IconIndex="0" Advertise="yes" />
</File>
and
<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut"
Guid="1E0D1741-57F0-4E22-89FC-4A189E2BB7E0">
<Shortcut Id="desktopSC"
Name="MyProduct"
Description="MyProduct description"
Target="[INSTALLFOLDER]TestX.exe"
Icon="IconTestX.exe">
</Shortcut>
<RemoveFolder Id="RemoveDesktopFolder"
Directory="DesktopFolder"
On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\[Manufacturer]\[ProductName]"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
I solved this problem by using WixUI_InstallDir in the WixUI library, which added a GUI which includes the option to start a repair.
Links about the WixUI dialog library:
http://wixtoolset.org/documentation/manual/v3/wixui/wixui_dialog_library.html
http://wixtoolset.org/documentation/manual/v3/wixui/dialog_reference/wixui_installdir.html

Wix Menu Shortcut Creation

I see two different ways how shortcuts in the start menu are being created in Wix (3.8.):
1)
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="CompanyMenuFolder" Name="Company">
<Component Id="MenuFolderComponent" Guid="*">
<RegistryValue Root="HKCU" Key="Software\Company\Product"
Name="MenuFolderComponent" Type="integer"
Value="1" KeyPath="yes"/>
</Component>
</Directory>
</Directory>
<!-- [...] -->
<Component Id='ManualComponent' Guid='*'>
<File Id='Manual' Name="Product.pdf" DiskId='1'
Source="Product.pdf" KeyPath="yes" >
<Shortcut Id="ManualStartmenuShortcut"
Directory="CompanyMenuFolder" Name="Product Manual" />
</File>
</Component>
2)
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="CompanyMenuFolder" Name="Company">
<Component Id="MenuFolderComponent" Guid="*">
<Shortcut Id="StartmenuShortcut" Directory="CompanyMenuFolder"
Name="Product" WorkingDirectory='INSTALLDIR'
Icon="Product.exe" IconIndex="0"
Target="[#ProductExecutable]" />
<RemoveFolder Id='CompanyMenuFolder' On='uninstall' />
<RegistryValue Root="HKCU" Key="Software\Company\Product"
Name="MenuFolderComponent" Type="integer" Value="1"
KeyPath="yes"/>
</Component>
</Directory>
</Directory>
Is any of these methods preferred and if so, why?
Thanks :)
A shortcut can be "advertised" - pointing to a component contained in a product, or "non-advertised" - pointing to a specific target path (Shortcut element documentation).
Option 2) is setting the target field of the non-advertised shortcut to Target="[#ProductExecutable]" - which is a property identifier that seems to point to the projects main executable in this case. It can point to a folder and an URL too as examplified here.
Option 1) also creates a non-advertised shortcut since the advertised attribute defaults to no, but here you have left out the Target field and it hence defaults to its parent component's key file.
In essence flexibility is allowed to account for the creation of different types of shortcuts and to allow for the concept of advertised and non-advertised shortcuts.

WiX missing 'Start In' property in desktop shortcut

I am working with WiX from last 5 month with no issues. Recently, i am in need to have "StartIn" property in App Desktop shortcut. By default, its empty.
Here is my full Installer code.
I am working with below code:
<Component Id="myapplication.EXE" DiskId="1" Guid="*">
<File Id="myapplication.EXE" Name="My Application.exe"
Source="D:\My Application\My Application.exe">
<Shortcut Id="desktopShortcut" Directory="DesktopFolder"
Name="My Application" WorkingDirectory="INSTALLDIR"
Icon="DesktopIcon.exe" IconIndex="0"
Description="My Application Description" />
<Shortcut Id="ExeShortcut" Directory="ProgramMenuDir"
Name="My Application" Icon="StartMenuIcon.exe" IconIndex="0" />
</File>
</Component>
But didn't work.
I have also tried adding "Target" property:
<Shortcut Target= "INSTALLDIR" Id="desktopShortcut" Directory="DesktopFolder"
Name="Virtual Sim Center Beta" WorkingDirectory="INSTALLDIR"
Icon="DesktopIcon.exe" IconIndex="0"
Description="My Application Description" />
but getting error message:
The Shortcut/#Target attribute cannot be specified when the Shortcut
element is nested underneath a File element.
This script bellow is working for my WIX:
....
<!-- Desktop Menu -->
<DirectoryRef Id="DesktopFolder">
<Component Id="FooDesktopShortcutMenu" Guid="*">
<Shortcut Id="FooApplicationDesktopShortcut"
Name="Foo Application"
Description="The Foo is Cool!"
Target="[#FooMainApp]"
WorkingDirectory="INSTALLFOLDER"
Directory="DesktopFolder"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\FooApplication"
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
....
<!-- Tell Wix -->
<Feature Id="ProductFeature" Title="FooSetup" Level="1">
.....
<ComponentRef Id="FooDesktopShortcutMenu"/>
.....
</Feature>
.....
Glytzhkof is right and so is your WiX source - just put it under the Component.
In addition to the answer by #Adiono check whether the 'WorkingDirectory' folder actually contains the 'Target'.
The 'Start in' of my shortcut was blank even when both 'WorkingDirectory' and 'Target' had valid values, but the 'Target' was not present in the 'WorkingDirectory'.
I don't have Wix set up to try this, but you can try to move the Shortcut element up to be nested under the Component element and not the File element. Then set the WorkingFolder attribute. Try something like this.

wix - shortcut icon for website

I'm new on wix. In need to create a shortcut to a local website.
It works fine and creates the shorcuts, but it doesn't show any icon on start menu and desktop... The website has favicon file and when I open the site I can see it perfectly - I just don't see it in the shortcut. I tried to google it but I didn't find a good answer for util:InternetShortcut..
My code is:
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcutBBBApp" Guid="---">
<util:InternetShortcut Id="ApplicationStartMenuShortcutBBBApp"
Name="BBB"
Target="http://localhost/BBB"/>
<util:InternetShortcut Id="ApplicationDesktopShortcutBBBApp"
Name="BBB"
Directory="DesktopFolder"
Target="http://localhost/BBB"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\BBB" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
There is an easier solution for that problem. Instead of using InternetShortcut, you can just use the normal Shortcut and use a trick to set the target being a url.
<SetProperty Id="URL" Value="http://yourpage.com" Sequence="execute" Before="CreateShortcuts" />
<Shortcut Directory="DesktopFolder" Id="WebShortcut" Name="Your Page" Description="Your Page Description" Target="[URL]" Icon="IconDesktop">
<Icon Id="IconDesktop" SourceFile="images\icon.ico" />
</Shortcut>
"SetProperty" can be placed somewhere in your Product tag.
"Shortcut" should be placed instead of "InternetShortcut".
It is important to have the property [URL] as a Target. As a Property it can be an url. Diretctly written it doese not work.
There might be warnings in heat/candle/light, they can be ignored.
InternetShortcut doesn't support specifying an icon like a normal Shortcut. There's an open feature request for that. Technically, IUniformResourceLocator shortcuts in Windows don't support icons, though IShellLink shortcuts do.
A little late answering this, but just needed to do the same thing. The approach I took was to use the iniFile element to write out a url file.
Two points of interest with this approach:
Since the shortcut is on the desktop and the icon file is located elsewhere on the file system, I needed to create separate components to deploy the icon file.
If the MSI is ran as a normal user with UAC turned on, the icon is not set for the shortcut. Once I disabled UAC prior to installing, the icon was set correctly.
<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="ProductInternetShortcut" Guid="{YOUR_GUID_HERE}" >
<IniFile Id="url_name"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="URL"
Value="https://my.url.com/" />
<IniFile Id="url_target"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="Target"
Value="https://my.url.com/" />
<IniFile Id="url_idlist"
Action="createLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="IDList"
Value=" " />
<IniFile Id="url_HotKey"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="HotKey"
Value="0" />
<IniFile Id="url_icon"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="IconFile"
Value="PATH_TO_ICON_FILE_ON_WORKSTATION" />
<IniFile Id="url_iconIndex"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="IconIndex"
Value="0" />
<RegistryValue Root="HKCU" Key="Software\COMPANY\PRODUCT" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="ProductFolder">
<Component Id="ShortcutIcons" Guid="{YOUR_GUID_HERE}">
<File Id="filProductIcons" KeyPath="yes" Source="PATH_TO_ICON_FILE_ON_DEVELOPER_MACHINE" />
</Component>
</DirectoryRef>
</Fragment>
In Wix you can create an InternetShortcut with an icon via the InternetShortcut Element (Util Extension).
Below is an example from an app I'm working on of adding a link to a website with an icon via the <InternetShorcut> element and placing that link on both the Desktop and the Start Menu.
Note, you may have to put the "util" prefix in front of the element name like so although I didn't have to do that: <util:InternetShortcut>.
<Directory Id="ProgramMenuFolder" Name="ProgramMenuFolder">
<Directory Id="ProgramMenuFolder.MyApplicationName" Name="MyApplicationName">
<Component Id="Component.Uninstall" Guid="215c7bec-7967-43e6-8f01-72c27fbb2a98">
<CreateFolder/>
<RemoveFolder Id="ProgramMenuFolder.MyApplicationName" On="uninstall"/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
<RegistryValue Value="0" Type="string" KeyPath="yes"/>
</RegistryKey>
</Component>
<Component Id="InternetShortcut" Guid="215c7bec-7967-43e6-8f01-72c22e505f09">
<InternetShortcut
IconFile="[INSTALLDIR]\icon.ico"
IconIndex="0"
Name="Admin Page"
Id="InternetShortcut"
Target="http://localhost:4444"
Type="link"
xmlns="http://schemas.microsoft.com/wix/UtilExtension"/>
<CreateFolder/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
<RegistryValue Value="0" Type="string" KeyPath="yes"/>
</RegistryKey>
</Component>
</Directory>
</Directory>
<Directory Id="DesktopFolder" Name="DesktopFolder">
<Component Id="InternetShortcut.1" Guid="B27DF351-6EDA-4BEF-A3AC-F12313260203">
<InternetShortcut
IconFile="[INSTALLDIR]\icon.ico"
IconIndex="0"
Name="Admin Page"
Id="InternetShortcut.1"
Target="http://localhost:4444"
Type="link"
xmlns="http://schemas.microsoft.com/wix/UtilExtension"/>
<CreateFolder/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
<RegistryValue Value="0" Type="string" KeyPath="yes"/>
</RegistryKey>
</Component>
</Directory>
<Feature Id="Complete" Title="Complete" Absent="allow" Level="1">
<ComponentRef Id="InternetShortcut"/>
<ComponentRef Id="InternetShortcut.1"/>
</Feature>
Also, see How To: Create a Shortcut to a Webpage

Wix: How to create a desktop shortcut pointing to a virtual drive under Computer

I would like to add a shortcut on the desktop which points to a virtual drive mounted under "Computer". This drive doesn't have a letter associated with it. I've successfully added a link to an executable, but all tries with Explorer has failed. When I add this shortcut manually it gets the following shortcut (in properties): Computer\MyProduct
I've tried the following:
<Component Id="DesktopShortcut" Guid="8EF63340-10D5-4583-9E28-F2EFFA666761">
<CreateFolder />
<RegistryKey Root="HKCU" Key="Software\MyProduct\Install" Action="createAndRemoveOnUninstall">
<RegistryValue Name="DTSC" Value="1" Type="integer" KeyPath="yes" />
</RegistryKey>
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="My Product" Icon="yoobitsIcon" Target="Computer\MyProduct" />
</Component>
Any ideas?
One possible solution is to add the shortcut in as a .lnk file and include as a regular file into the Desktop folder during install.
<Directory Id="DesktopFolder" Name="Desktop">
<Component Id="MyProductDesktopShortcut" Guid="A47E6BEB-C7D6-4725-A94F-C6C52A55F31C">
<RegistryKey Root="HKCU" Key="Software\MyProduct\DesktopShortcut" Action="createAndRemoveOnUninstall">
<RegistryValue Name="DTSC" Value="1" Type="integer" KeyPath="yes" />
</RegistryKey>
<File Id="MyProductDesktopShortcutFile" Name="MyProduct.lnk" Source="MyProduct.lnk" DiskId="1" />
</Component>
</Directory>
Drawback:
The icon registered in the .lnk file will not be correct if the application gets installed in a different directory than what is expected. In this scenario this will result in a default folder icon and the adjust to the correct icon once you navigate to that virtual drive.