gazunk
Posts: 3
Joined: Mon Aug 23, 2021 11:21 pm

Launch Application with PS Automation

Fri Sep 10, 2021 3:54 pm

My installer generated by a PowerShell script works, but I don't get the "Launch Application" final tick box in the wizard.

After reading around my best guess was to have something like $project.PropertyComponent.NewProperty("FILE_TO_LAUNCH","[#MyApp.exe]") but that doesn't seem to work.

Comparing my .aip with one created in the application, the launch part seems to come from

Code: Select all

  <COMPONENT cid="caphyon.advinst.msicomp.MsiCustActComponent">
   ... snip ...
    <ROW Action="AI_LaunchApp" Type="1" Source="aicustact.dll" Target="[#Myapp.exe]"/>
but I don't know how to specify that in the PS object.

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Launch Application with PS Automation

Mon Sep 13, 2021 9:42 am

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
powerShellLaunchFile.png (19.94KiB)Viewed 8310 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
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”