0

I successfully created a msi installer package using WiX. Now I need to access the file name (the name which is displayed in explorer, like "myPackage.msi") of the msi installer package in the code (note, user can change the installation package name to anything he/she wants). Is there any way to identify the package file name? Using of custom actions is also allowed.

FYI, I need the file name to create a config file based on the package file name, name would be unique for different user.

Suresh
  • 69
  • 1
  • 8
  • Why would you want to allow someone to rename your .msi file? Could you clarify what exactly you mean by "file name" and "package file name"? It looks like they are both referring to the .msi file but that wouldn't make sense. – Starceaker Dec 28 '15 at 13:28
  • You shouldn't change the name of the MSI after the install has been started or after it's been installed because maintenance operations will fail searching for the MSI file. – PhilDW Dec 28 '15 at 21:31

2 Answers2

0

You could read the OriginalDatabase property, at least for a first-time install. It gets a little messier during maintenance, however, as a cached .msi package does not retain the original name, and you would have to store it, or perhaps use something like MsiGetProductInfo(..., INSTALLPROPERTY_PACKAGENAME, ...) (only documented to work for advertised packages, not installed ones). So, despite not fully understanding what you're trying to do here, I do not recommend the approach I think you describe.

Thus I would suggest a per-user location for a file of a known name, such as %LOCALAPPDATA%\YourCompany\YourProduct\someconfig.file. This makes it easier for updating or consuming the file outside the context of the installation.

Michael Urman
  • 15,737
  • 2
  • 28
  • 44
  • Can I use MsiGetProductInfo() inside the installer to get its own product Info? And regarding OriginalDatabase property, how can I access this in custom action of wix? Thanks – Suresh Dec 29 '15 at 14:15
  • @Suresh If you don't already know how to access properties in a custom action, you should avoid writing them. Go instead with a simpler architecture of multiple msi files if necessary. – Michael Urman Dec 29 '15 at 18:42
0

Regarding commandline options: look at this topic WIX: How to Select Features From Command Line

It shows you how to group features / components and then how you can select them using commandline options.

PS: Could you give a more concrete example so we can understand why certain files need to be manipulated? What are these user settings that influence the installer?

Edit: Previous answer (after you provided more info it became clear that this is not useful).

Create a variable (in a separate Variables.wxi file):

<?xml version="1.0" encoding="utf-8"?>
<Include>
  <?define ProductName = "..." ?>
  <?define CompanyName = "..." ?>
</Include>

You can then use this variable everywhere, for example:

<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="..." Manufacturer="$(var.CompanyName)" UpgradeCode="....">
Community
  • 1
  • 1
Starceaker
  • 631
  • 2
  • 5
  • 14
  • How will this help with my problem? I need filename in "filename.msi". I can't find this being done anywhere in your solution. Can you please explain. – Suresh Dec 29 '15 at 13:59
  • I'm trying to understand your problem and I was hoping this could help you in some way. I just read your comment above "Environment name is automatically added by a script in server based on some user info and user gets file of the format specified above.". Perhaps you should consider other options to "manipulate" your files such as command line arguments. – Starceaker Dec 29 '15 at 14:57