Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why [ProductCode] can be expaneded while [ProductName] can not?

Tags:

wix

I have WiX code like this:

<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 expaneded while [ProductName] can not, why is it so? Then how to reference product name define in element?

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

Code screen shot ProductName is not expanded, damn

like image 404
Jimm Chen Avatar asked May 04 '17 02:05

Jimm Chen


People also ask

Why is giving a name to a product not enough?

Answer: Giving a name to a product is not enough as it is also necessary to imbibe the product with certain values that a customer can identify with. Creating such a link between the customer and the product will enable him/her to make a positive choice about purchasing the product.

Why is it important for a product to have a name?

It's part of making the right first impression It's the first thing your customer will interact with when they're looking for the right product or service to solve their issue. A high-quality name is memorable, and it helps your customer to identify you.

What does it mean if a product name?

Product name means a name, designation or trademark that identifies a product.

What is the difference between product name and brand name?

A product is made by a company and can be purchased by a consumer in exchange for money while brands are built through consumer perceptions, expectations, and experiences with all products or services under a brand umbrella. For example, Toyota's product is cars.


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 expansion happens when the product is installed.

In the Shortcut table in the MSI database:

  • The Arguments column is type Formatted, so [ProductCode] will be expanded when the product is installed.
  • The Name column is type Filename, so [ProductName] and [ProductVersion] will not be expanded when the product is installed.

You could use WIX properties, which are expanded 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" />
like image 199
bradfordrg Avatar answered Nov 15 '22 11:11

bradfordrg


Properties in brackets are expanded in "formatted" attributes. For shortcuts, Shortcut table defines that Arguments is formatted but the Name is not.

You may 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)"
like image 37
dvorn Avatar answered Nov 15 '22 09:11

dvorn