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:
Hope this helps.
All the best,
Catalin
FOLLOW US
Get the latest news in Application Packaging