Hi,
First, you need your file in the project, for example:
Code: Select all
$project.FilesComponent.AddFile($project.PredefinedFolders.ApplicationFolder, "C:\test.txt")
Then, you can launch a file in PowerShell automation using a command line like this:
Code: Select all
$ca = $project.CustomActionsComponent.NewLaunchFileFromDisk("[#test.txt]")
$ca.ExecutionTime = "deferred"
You need to save the custom action in a variable to change the execution time on "deferred", because the default one is "immediately".
- powerShellLaunchFile.png (19.94 KiB) Viewed 9427 times
You can find the others custom actions commands in the
"CustomActionsComponent" component. Here is a sample project code example:
Code: Select all
$advinst = New-Object -ComObject AdvancedInstaller
$project = $advinst.CreateProjects("professional")
$project.ProductDetails.Name="test"
$project.FilesComponent.AddFile($project.PredefinedFolders.ApplicationFolder, "C:\test.txt")
$ca = $project.CustomActionsComponent.NewLaunchFileFromDisk("[#test.txt]")
$ca.ExecutionTime = "deferred"
$project.CustomActionsComponent.NewLaunchFileFromDisk("[#test.txt]")
$project.SaveAs("C:\custom.aip")
After further investigation, I saw that our help is not updated for this component. I'm sorry for that, we will update this as soon as possible.
Thank you for bringing this to our attention!
Hope this helps! If you have any other questions, please don't hesitate to contact us.
Best regards,
Liviu