We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

pforsbom
Posts: 23
Joined: Mon Apr 01, 2019 11:03 am

Copy files to location other that APPDIR

Hi
In my solution I am copying some files to my APPDIR, and then I want some files copied to another location that I have stored in a custom property. This is the path to another application. My installer is adding files to this application as a plugin.
I try the Copy/Move File operation but that seems to only copy files TO the APPDIR or any other predefined folders. I tried doing it with a Custom Action but no matter what sequence I set it to, the install files does not exist yet.
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Copy files to location other that APPDIR

Hello,

This probably happens because you have scheduled your custom action before the "Add Resources" action group. Please keep in mind that during this action group, the files are copied over to the target machine (during the "Install Files" standard action.

Also, it is also important to take into consideration the location where you are trying to write your files. For example, if you are trying to copy the files to a location that requires elevated permissions (e.g. "C:\Program Files"), then your package must be run as administrator.

Let's have the following example: two text files in the "Application Folder" ("Files and Folders" page). After installing them on the target machine, you want to copy them to another folder (e.g. "C:\Users\Sample"). Let's say we want to do this through a PowerShell script. The cmdlet that copies a file from a location to another looks similar to this:

Code: Select all

Copy-Item "path_where_your_file_resides" -Destination "the_destination"
That being said, in order to achieve those said above, you can proceed as it follows:
  • go to "Custom Actions" page and add a "PowerShellScriptInline" custom action with sequence. In order to add a custom action with sequence, simply press the "Add custom action with sequence" button which is placed to the right side of the custom action's name.
  • after adding the custom action, it is time to configure it. To do so, please proceed as it follows:
"Execution Time" -> "When the system is being modified (deferred)"

"Execution Options" -> all 3 checked.

"Execution Stage Condition" -> uncheck "Uninstall" and "Maintenance"

The custom action code can look something as it follows:

Code: Select all

Param($appDir)

# Your code goes here.

Copy-Item "$appDir\one.txt" -Destination C:\Users\Sample
Copy-Item "$appDir\two.txt" -Destination C:\Users\Sample
Please find attached a sample project I have created for your reference:
CopyFileCA.aip
(13.89 KiB) Downloaded 519 times
Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
pforsbom
Posts: 23
Joined: Mon Apr 01, 2019 11:03 am

Re: Copy files to location other that APPDIR

Hi
Thank you this helped :Setting the "Execution Time" -> "When the system is being modified (deferred)" helped me run my Custom Action at the correct sequence.

I am however having problems getting a session property. In a custom dialog the user selected the path from a ListBox. I can not seem to get this path from my custom action. I am trying session["MyListBoxProperty"] but this throws an error: "Cannot access session details from a non-immediate custom action"
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Copy files to location other that APPDIR

Hello,
Thank you this helped :Setting the "Execution Time" -> "When the system is being modified (deferred)" helped me run my Custom Action at the correct sequence.
You are always welcome. Glad it worked.
I am however having problems getting a session property.
Installer Properties are available only during the immediate stage of the install execution process. After this stage is complete all property values are set to empty strings.

The exception to this rule is the special CustomActionData property which keeps its values through all of the stages even during deferred, rollback and commit.

Please have a look on the "How to access installer properties from deferred custom actions" article which I think you may find useful.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”