mmichal
Posts: 2
Joined: Thu Mar 24, 2016 12:36 am

Pass script parameters in "Run PowerShell script file" custom action

Thu Mar 24, 2016 12:58 am

It would be helpful to be able to pass script parameters when using the "Run PowerShell script file" custom action similar to what the "Run PowerShell inline script" custom action allows. I would prefer to manage the script outside of the AIP file for editing purposes (copy/paste gets tiresome) and to be able to test the script separate from the installer project without losing the parameter functionality.

Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Pass script parameters in "Run PowerShell script file" custom action

Thu Mar 24, 2016 10:48 am

Hello,

To get a property simply include a line with the following syntax in your file:

Code: Select all

$propValue = AI_GetMsiProperty YOUR_PROP
Where YOUR_PROP is the property name.

To set a property simply include a line with the following syntax in your file:

Code: Select all

AI_SetMsiProperty YOUR_PROP <VALUE> 
Where YOUR_PROP is the property and <VALUE> is the value assigned to it.

Note that setting MSI installer property values works only when the PowerShell custom action has "Immediate" execution time. It does not work if the execution time is set to "When the system is being modified(deferred)". Also, the properties will be updated after the powerShell custom action runs.

Let me know if that helped.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

JTrax
Posts: 12
Joined: Wed May 04, 2016 7:13 pm

Re: Pass script parameters in "Run PowerShell script file" custom action

Wed May 04, 2016 7:16 pm

Does this work the same for reading the location of a file? So when we pass in params we put a [ ] and you can place a property in the [ ] or you can pick a file, which I assume gives you the resolved path to the file. does that work the same with the AI_GetMsiProperty command or do we specify the file info differently?

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Pass script parameters in "Run PowerShell script file" custom action

Wed May 11, 2016 9:30 am

Hello,

First of all I apologize for our delayed reply.

Yes, this should work for any formatted reference, including file references too (i.e. [#myApp.exe]). Please note that if the resolved file path may contain spaces it is recommended that you enclose it between quotes when adding it in "Script parameters" field:

Code: Select all

-firstPsParam "[#myApp.exe]"
If you have any questions just let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”