1

I'm using advanced installer for creating msi package I want copy some files and folders after installation completed to "[APPDIR]" (I know I can do this with add files and folder to files and folder section in advanced installer but I don't want to do that because my files and folder are dynamic in each installation in customer machine) I write an inline PowerShell script like below

> Param( [string] $source, [string] $dest )
$exclude = @('web.config')
> Get-ChildItem $source -Recurse -Exclude $exclude | Copy-Item
> -Destination {Join-Path $dest $_.FullName.Substring($source.length)}

and in the parameter section, I fill like this "[SourceDir]Project", "[APPDIR]Project"

but it doesn't work. Why?

0

2 Answers 2

1

Abbas has since confirmed that the problem was one of command-line (parameter) syntax:

The parameter section - what to pass to the PowerShell script from Advanced Installer - was filled in as:

"[SourceDir]Project", "[APPDIR]Project"  # !! WRONG, due to the comma

whereas it should have been:

"[SourceDir]Project" "[APPDIR]Project"  # OK: *space-separated* arguments

Calling scripts/functions/cmdlets in PowerShell works as it does in shells, not as in programming languages; that is, you must separate the arguments being passed with spaces.

By contrast, using , between tokens constructs an array that is passed as a single argument.

From PowerShell run Get-Help about_Command_Syntax for more information.

Sign up to request clarification or add additional context in comments.

Comments

0

It depends, you need to give more details. What are the execution settings for your PS custom action?

Have you checked the verbose log to see the params are passed correctly?

Your custom action should be scheduled as deferred with no impersonation, so it is executed after the APPDIR folder is created by the setup package and it has all the rights to write in that location.

Also, you should add rollback and uninstall custom actions to cleanup the files, as during an uninstalled or a canceled/failed installation, those resources will not be cleaned up by Windows Installer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.