cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
varunAdb
Level 4

copying file only if particular application exists

Hi all,

Suppose i need to do installation in which all the components will be stored at a default value of [INSTALLDIR] and are self-registered. only one file which is a plug-in for adobe acrobat/reader needs to be copied at a specific location ONLY if these applications(acrobat/reader) exists. How to i move forward with this without writing any script?

Thanks
Labels (1)
0 Kudos
(11) Replies
Kelter
Level 10

1. create a system search entry to look for a reg key to verify that acrobat is installed. let's say that you store the result of that search in a property called [ACROBAT_INSTALLED]

2. set the condition for the component that contains this plugin to ACROBAT_INSTALLED

3. There is no step 3. It's really just that simple.

🙂
0 Kudos
varunAdb
Level 4

Thanks for your reply,

But the question remains unanswered. How can I "cppy" a file to that location returned by value of that key? I actually have to copy .api file at that location.

Regards
0 Kudos
Kelter
Level 10

you're talking about copying a file that's already on the user's system, or one packaged with your product?
0 Kudos
varunAdb
Level 4

The file is packaged with installer. I only need to place it at particular location as explained but and this is conditional. In case destination folder doesn't exist we won't be copying that file anywhere else on that destination machine.

Regards
0 Kudos
Kelter
Level 10

Use a system search to find the Install path in the registry. On the last page of the System Search wizard, you will have the option of what to do with the value that you are reading from the registry. one of the options is to use it as the destination for a component. This makes things much easier as the wizard will make the necessary entries in the directory table as well as assigning the directory identifier as the destination of the component you select.

If you "just store the value" in a property at the end of that wizard, you may need to do a little extra work to make the component use that value as the destination for the component. Let's say you are storing the value found at "HKLM\SOFTWARE\Adobe\Acrobat Reader\InstallPath" in a property called [ACRO_INST_PATH]. You may need to create a "Set A Directory" CA that will assign the property value to a directory identifier of the same name. You could then use the same thing as the condition and the destination of your component.

It seems that the installation path value is stored in the registry under a specific version of acrobat reader. You may need to ignore the System Search, and create a Custom Action to search under the "HKLM\SOFTWARE\Adobe\" key to find an "InstallPath" value, and then to use MsiSetProperty() to set that property. InstallScript makes writing simple things like that very easy.

Hope that helps!
0 Kudos
varunAdb
Level 4

Thanks Kelter,

That really helped. One thing I am unable to understand is where is this property (one generated on using system search) stored? I dont find it in property manager and in case the specified property is not set(may be because search failed) in that case what happens to this property.
I tried using the result of search to store the value in component and set the condition to be the property assuming on search failure NOT should evaluate to true but this doesnt come out to be the case.

Suppose i use c++ to write custom action to search the relevant folder path reading a specific value in registry. How can then I place the .api only at that location. Do msi provide us with any such functions?

Regards
0 Kudos
Kelter
Level 10

The property manager is a view into the property table. The property won't exist until runtime when the AppSearch action runs, and even then, it'll only exist if it finds that reg entry. If you're using a custom action to do the search, then the property gets created when you call MsiSetProperty.

Log the installation, and check the AppSearch part of the log. You'll see a line or two in there for each system search you've specified (although there probably won't be enough information in it to tell which log entries apply to which searches...unless they find something, in which case you'll see a line in the log for the property getting set.) You'll see the property setting during the CA if that's how you implement it.

Supposing you were to write the CA in C/C++ or InstallScript (which I like for its simplicity and because it's integrated with the installation build, it's quick to make a change, and rebuild in one step...), you may want to experiment with this function: MsiSetTargetPath();. That should enable you alter the path of a directory variable.
0 Kudos
Kelter
Level 10

Okay, correction: you might need to schedule that CA after the CostFinalize SA. I don't think you can do anything directory-related until after the directory manager has been initialized by the costing actions.
0 Kudos
varunAdb
Level 4

That clears the concept to great extent. as am a new in this installer subject kindly forgive me for overwhelming you with ques. Suppose i have to continue with C++, then in writing custom actions what method i find is to do edition of database tables. is this the correct approach?
Let me explain with example, taking previous problem of putting my .api i check for both acrobat and reader and place it in both if both exists. what method i find is editing duplicate table(if that is possible?). is this the correct way of handling taking that whole of the custom action from finding the folder to placing copies of .api is to be coded?

Regards
0 Kudos
Kelter
Level 10

very interesting; i didn't think about the "multiple versions" issue. perhaps what you need is to-
- create a component for each version of Acrobat.
- Set the target path for each component so that it's based on a different property\directory identifier, such as ACROBAT__PATH
- Write a custom action that sets both a property and a directory for each found version of Acrobat.
- - The Property will be used in the condition for the component.
- - The directory will obviously be used to set the target for the component.
- Schedule the Custom action after the CostFinalize action.

You now have a custom action that runs every time the installation is launched (any system data that you gather during Install that is used in feature or component conditions MUST be read in every time you launch your installation!!! otherwise in maintenance mode, unpredictable stuff can happen.) You also have as many components as you have Supported Acrobat versions. This Custom action sets properties which will determine for which versions of Acrobat your file needs to be installed. It also sets the target directory for each of the installed versions of Acrobat. This should do it for ya!
0 Kudos
varunAdb
Level 4

Thanks Kelter,

All that really helped a lot... 🙂
0 Kudos