Why [ProductCode] can be expanded but [ProductName] cannot?

I have WiX code:

<DirectoryRef Id="MyShortcutsDir">
    <Component Id="CMP_StartMenuShortcuts" Guid="62A9F5D2-F9D9-4F9B-8382-D470E11B2332">
        <Shortcut Id="docEng" Name="UFCOM user guide - ENG (pdf)" Target="[INSTALLFOLDER]UFCOM user guide - ENG.pdf" />
        <Shortcut Id="docChs" Name="UFCOM user guide - CHS (pdf)" Target="[INSTALLFOLDER]UFCOM user guide - CHS.pdf" />
        <Shortcut Id="UninstallShortcut" Name="Uninstall [ProductName] ~ [ProductVersion]" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]" Description="Remove UFCOM from your Windows" />
        <RemoveFolder Id="RemoveMyShortcutsDir" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\Newland Auto-ID\UFCOM" Name="installed" Type="integer" Value="1" KeyPath="yes" />
        <!-- On Win7, these shortcuts(.lnk) resides in "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\UFCOM" -->
    </Component>
</DirectoryRef>

      

But I find that [ProductCode] can be decrypted and [ProductName] cannot, why is that? Then, how do you specify the name of the product in the item?

<Product Id="*" Name="UFCOM Driver 1.3.6" ... >
</Product>

      

Screen encoding ProductName is not expanded damn

+3


source to share


2 answers


Property names in square brackets are only expanded by the MSI installer for data in Formatted column types in the MSI database. The extension occurs when the product is installed.

From the Shortcut table in MSI database:

  • In the Arguments column: Formatted , so it [ProductCode]

    will be expanded upon product installation.
  • The Name column is of type Filename[ProductName]

    and [ProductVersion]

    will therefore not be expanded upon product installation.


You can use WIX properties that are extended during the WIX build process. For example:

<?define ProductName='My Product Name' ?>
<?define ProductVersion='X.Y.Z' ?>

<Shortcut Id="UninstallShortcut" 
     Name="Uninstall $(var.ProductName) ~ $(var.ProductVersion)" 
     Target="[System64Folder]msiexec.exe" 
     Arguments="/x [ProductCode]" 
     Description="Remove UFCOM from your Windows" />

      

+5


source


Properties in parentheses are extended in "formatted" attributes. For shortcuts, the Shortcut Table determines that Arguments are formatted, but no Name is specified.

You can define a variable

  <?define MyProductName = "UFCOM Driver 1.3.6" ?>

      



and then use it in both Product / @ Name and Shortcut / @ Name:

<Product Name="$(var.MyProductName)"

<Shortcut Name="Uninstall $(var.MyProductName)"

      

+1


source







All Articles