PDA

View Full Version : Install files to a registry specified location



sgmartin
11-12-2003, 04:17 AM
Hi all,

I'm making an installer which has to install only one file at several folders specified by registry entries which must be at the user's system registry before running the installation.

I'm trying to do it using the "System Search" searching for the registry entries and storing its values at different properties, my problem is that later, I don't know how to copy my file to that locations stored at that properties.

So here are my questions:
a) Is there any way to do what I want as I was trying to?
b) Is there any other better, simpler way to do this?

Thanks in advance,
Sergio Gallego.

KathyMorey
11-12-2003, 10:05 AM
Since you mentioned System Search, I'm assuming you have an InstallScript MSI project.

What I've done in the past is retrieve the paths from the registry using System Search, but I always use the option for "registry entry that contains other data". I store that in a public property.

If you're installing the file through a component, you can use a type 35 custom action sequenced after CostFinalize to set the destination folder for the component to the value in the property. I always condition the action on the existence of the property from System Search.

If you're installing the file in your script, you can use MsiGetProperty to get the path, then CopyFile or XCopyFile to copy the file to the proper destination.

HTH

sgmartin
11-13-2003, 05:43 AM
Thank you Kathy,

I was trying to do as you adviced, retrieving the paths from the registry using System Search, using the option for "registry entry that contains other data", but I was wordering what do you mean with "I store that in a public property". At the System Search Wizard step "What do you want to do with the value?" I give a name for the property and mark "Just store the value in the property".

That property, must be defined at the "Property Manager"? How do you make it public? I've tried defining it and not, but anyway then at the script I can't retrieve the value (MsiGetProperty does not fail but returns an empty value).

My CustomAction is a call to a dll that exports only the function called by the action, is that a good practice or there's anything better?

And also, I have placed the custom action at the end of the Installation/Execute sequences to ensure the file I'm going to copy to the property specified locations has been installed (hope that's the correct place to run it), and here the problem is the action is executed both when installing and unistalling the product. How can I prevent it to be executed when unistalling?

Thanks for your time,
Sergio

sgmartin
11-13-2003, 06:04 AM
It's me again...

If the property is defined at the Property Manager, MSIGetProperty returns the value that was given there, but not the value that the System Search should have modified. What am I doing wrong?

Thanks again,
Sergio.

KathyMorey
11-13-2003, 10:06 AM
.I was trying to do as you adviced, retrieving the paths from the registry using System Search, using the option for "registry entry that contains other data", but I was wordering what do you mean with "I store that in a public property". At the System Search Wizard step "What do you want to do with the value?" I give a name for the property and mark "Just store the value in the property".

First, a public property is simply one with all caps, e.g., MYPROPERTY. Just enter it as you said you were doing above.

Don't define it in the Property Manager. The trick here is that the property won't exist unless it's created by the AppSearch action (which is what System Search sets up).

then at the script I can't retrieve the value (MsiGetProperty does not fail but returns an empty value).

How are you scripting MsiGetProperty? If you haven't done so, make sure you set the size of the buffer before you call it:

nBuffer = MAX_PATH + 1;
nResult = MsiGetProperty(ISMSI_HANDLE, "MYPROPERTY", szPath, nBuffer);

and make sure that you've put the code in an event or custom action that is called after the AppSearch action.

Last, you can condition you're custom action several ways - using "Not Installed" will allow it to run only during first-time installations. (Note that if you use major upgrades, they run as a first-time installation, which is probably okay.)

HTH

sgmartin
11-14-2003, 06:15 AM
Great Kathy!, I can read the property values now and the condition "Not Installed" is good enough for my requirements.

I have to deal now with copying the files but I think It will be easier :p

So, thanks again for your help!
Sergio.