tags:

views:

61

answers:

1

In my installer I need to do the following: obtain location of the external application from registry and create folders for my application executive and various files in this “parent” directory. I know how to get this directory from registry, but unfortunately the string I get looks like this: C:/Programm Files/Manufacturer/ExtApplication/extapp.exe.

For sure, it does not suit me. So, as I understand, I need to remove the “extapp.exe” part from it. I tried to do it via CustomAction using VBScript or JScript, but I am not experienced enough nether in both these scripts, nor wix itself. I read about Type51, Type 35, etc. CustomAction types, but I cannot get how I should 1) remove the part of the string; 2) use it in Directory element; 3) do all this before the installation of the files.

Will be grateful for any advice (without using Scripts as well).

+2  A: 

First, you shouldn't use script custom actions. They are very fragile:

http://blogs.msdn.com/b/robmen/archive/2004/05/20/136530.aspx

Here is how I would roll:

1) Use RegLocator/AppSearch to pull the registry value into a property at the beginning of the isntall. Then call out to a C++ custom action that parses off the file name. This custom action should be scheduled before CostInitialize.

You won't use a 51 or a 35 here, you'll use a Type 1 with a call to MsiSetProperty() which is equivilant to Type 51. The difference between 51 and 35 is you use 51 before costing and 35 after costing.

The name of the property you set should match the name of the Id for the Directory table row you are using. Any children of that row will be relative path'd to what you set it to.

Christopher Painter
I'm sorry, cannot you give an example? I've written a dll, but I don't know how to write a custom action so that I can set the Directory at last.
26071986
Sorry, I answer quesions, not provide complete solutions. If you go in Visual Studio you'll see File | New | WiX | C++ Custom Action. It'll set up a project for you. Search MSDN for examples of how to use MsiGetProperty() and MsiSetProperty(). Search StackOverflow to examples of how to remove a trailing backslash and then read up on how to insert a custom action into WiX.If you need an example of how to do all of this, I am always available for consulting.
Christopher Painter
Thank you for your advice and patience - at last I did it :)
26071986
Great to hear! One last thing... make sure you schedule the CA in both the UI and Execute sequence and to run only once. Also make sure you are using a secure property ( one that is both public and listed in secure custom properties ) to make sure it'll work when running either silently or elevated.
Christopher Painter