Azef123
Posts: 3
Joined: Thu Aug 07, 2014 1:11 pm

Get value TextBox Dialog with PowerShell Script

Dialog with text box
Dialog with text box
Capture.PNG (85.94 KiB) Viewed 7582 times
First, I am new and i try the software.

I am in "Architect" mode. I add a dialiog sequence with "Edit Box" and i would like get value enter by user in Powershell script.

How in the custom action (PowerShell script) can I get the text value ?
Attachments
PowerShell script to get value text box
PowerShell script to get value text box
Capture2.PNG (23.26 KiB) Viewed 7582 times
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Get value TextBox Dialog with PowerShell Script

Hello and welcome to Advanced Installer forums,

A custom action written in PowerShell can access Windows Installer properties with the help of _msiPropOutFile predefined temporary file:

Code: Select all

001: param($_msiPropOutFile)
Please take a look on the Run Windows PowerShell Script article for more details.

Let us know if that helped.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Azef123
Posts: 3
Joined: Thu Aug 07, 2014 1:11 pm

Re: Get value TextBox Dialog with PowerShell Script

Hello,

I found how to get value properties but in .vbs :|
1. In Dialogs menu, add Edit Box
2. Check name "Property Name" in right menu "Properties". (For me Property Name=EDIT_2_PROP)
3. In Custom Actions add "Execute inline script code"
4. Use script Type vbs
5.

Code: Select all

Dim text_box
text_box = Session.Property("EDIT_2_PROP")
MsgBox("Text enter by user: "+text_box)
6. Execute in Install only condition.

So, to get access properties use command Session.Property("YOUR_NAME_PROPERTIES")

Now, i try to do the same but in PowerShell. What is the equivalent command in PowerShell of Session.Property("YOUR_NAME_PROPERTIES") ?
I read the article and i continue to look for a solution.

Code: Select all

$msiProps = @{ "YOURPROP1" = [i]Session.Property("EDIT_2_PROP")[/i]; "YOURPROP2" = "abcd" }
$msiProps.Keys | % { "$_ : " + $msiProps.Item($_) } >> C:\testlog.txt 

This software it's very good and the graphic interface "user friendly".
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Get value TextBox Dialog with PowerShell Script

Hello,

I apologize I missunerstood your scenario.

It seems that power shell script does not have predefined functions to retrieve the value of a Windows Installer property. However, using our Run Windows PowerShell Script custom action, in order to achieve what you want you can access the edit box associated property (e.g. EDIT_BOX_PROP) within your PowerShell custom action like this:
1. in the "Script Parameters" field of your "Run Windows PowerShell Script" custom action add the following parameter:

Code: Select all

-myPropVal [EDIT_BOX_PROP]
2. within your PowerShell script code, declare the "myPropVal" parameter in the parameters section of your script like this:

Code: Select all

Param ($myPropVal)
3. after declaring the "myPropVal" parameter in the parameters section of your script body, you can access its value anywhere inside your script

If you have other questions, please let us know.

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

Return to “Building Installers”