wollka
Posts: 43
Joined: Sun Oct 22, 2006 6:30 pm

Copy file from [sourcedir]

Hi,

This is not an AI bug report, but i need a suggestion:

I need to copy some config file from the source folder (where .msi package is located) to the destination folder (i want to make custom builds of my program in this way).

Can you please tell me, how to make this custom action and how to ensure that this file will be removed on uninstall and will not prevent the deletition of destination folder on uninstall?

Thanks in advice,
Serhiy
wollka
Posts: 43
Joined: Sun Oct 22, 2006 6:30 pm

and how to set this custom action to work correctly if this file doesn't exist in sourcedir - if it isn't there, setup should continue without errors...

Thank you!
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,
I need to copy some config file from the source folder (where .msi package is located) to the destination folder (i want to make custom builds of my program in this way).
This can be done with a Copy/Move file operation in the "Files and Folders" view. Here is how you can do this:

1. Create a property in the "Install Parameters" page, let say MY_PROP.
2. Switch to "Files and Folders" page and add a "New Folder->Property Based" and select the property created at step 1.
3. This folder is not need to be installed, it's used only to have access to the SourceDir property. To delete this folder choose "Remove folder" option in the folder properties dialog.
4. Switch to "Custom Actions" page and add a new "Property Set With Formatted" custom action. In the "Property Name" type MY_PROP, in the "Formatted Text" type [SourceDir]. Use (Not installed) as execution condition.
5. Select the "Application Folder" in the "Files and Folders" page. Add a "New File Operation->File Copy/Move". For the source folder choose MY_PROP. As operation choose "Copy".

Note that if you want that file to be removed on uninstall you need to add a "File Removal" operation for it.

Hope this helps. If you encounter any problems please let me know.

Best Regards,
Gigi
_______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
wollka
Posts: 43
Joined: Sun Oct 22, 2006 6:30 pm

Thank you for great support! It works great!
MartinFH
Posts: 19
Joined: Thu Sep 20, 2007 1:32 pm

Copy file from [sourcedir] - not working

hy everybody

I followed exactly the steps given and I am receiving the following message during the installation process:

German language: "Zugriff auf Netwerkadresse [MY_PROP] war nicht möglich"
Translated into English language it means: "Access to network adress [MY_PROP] was not possible."

The value in between the brackets is the default value.

Here are chronologically the steps I have taken:
1. Add a new property named MY_PROP. Without supplying a default value I am not able to close the dialog. So I tried several values here i.e. [SourceDir].
2. Under Files and Folders I added a new property based folder and selected the property MY_PROP.
3. I choose the "Remove folder" option in the folder properties dialog.
4. In the page Custom actions I added a new "Property Set with Formatted" custom action under the Install sequence. The property name is MY_PROP and the formatted text is [SourceDir]. The execution expression is (not installed).
5. In the Files and Folders page I selected Application Folder and added a "New File Operation" for Copy. The source folder is MY_PROP. The source file is GENERIC_TZ60.DAT. The destination folder is AppDir and the destination file is GENERIC_TZ60.DAT. The operation is copy and for the value for Component I left the default "SHORTCUTDIR".

Do you have any idea what I am doing wrong - especially since Serhiy posted that everything is working great for him?

thanks for your earliest possible reply.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

You are encountering this behavior because you are using an incorrect value for the MY_PROP property. Note that [SourceDir] is not available when setting the value of a property in the "Install Parameters" page.

The solution is to use a valid property which can be recognized by Windows Installer (for example "C:\"). Also, please make sure that the custom action that sets the MY_PROP property is set before the "MoveFiles" standard action.

There is a similar approach in another post, please take a look:
http://www.advancedinstaller.com/forums ... +copy+move

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
MartinFH
Posts: 19
Joined: Thu Sep 20, 2007 1:32 pm

hy - thanks for the prompt response. So far your hint worked :D

have a nice one
ACarpenter@msn.com
Posts: 15
Joined: Sat Aug 11, 2007 12:59 am

Copying Existing File

I have tried the identical steps in this post and it still does not copy the file:

1. Add a new property named MY_PROP. Default value = C:\ (why? does this even matter?).
2. Under Files and Folders I added a new property based folder and selected the property MY_PROP.
3. I choose the "Remove folder" option in the folder properties dialog.
4. In the page Custom actions I added a new "Property Set with Formatted" custom action under the Install sequence. The property name is MY_PROP and the formatted text is [SourceDir]. The execution expression is (not installed).
5. In the Files and Folders page I selected Application Folder and added a "New File Operation" for Copy. The source folder is MY_PROP. The source file is network.xml. The destination folder is AppDir and the destination file is netwrok.xml. The operation is copy and for the value for Component I picked a random file.

Compile and run -no errors but network.xml (located in same directory as msi) is NOT copied.

"make sure that the custom action that sets the MY_PROP property is set before the "MoveFiles" standard action. "

What does this mean? Where is this done?

Thanks.

Carp
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
1. Add a new property named MY_PROP. Default value = C:\ (why? does this even matter?).
Please note that if you do not initialize this property with a valid path, the costing of the MY_PROP folder cannot be done, therefore the installation package will not work (Windows Installer verifies all the folders in the "Files and Folders" page that contain files before the installation starts).
"make sure that the custom action that sets the MY_PROP property is set before the "MoveFiles" standard action. "
What does this mean? Where is this done?
You can add the "MoveFiles" standard action under "InstallExecuteSequence" by using the "Show Standard Action" button on the toolbar in the "Custom Actions" page.

If the problem persists please send us the AIP (if it doesn't contain confidential information) or a small test case reproducing this behavior to support at advancedinstaller dot com so we can investigate this issue.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”