Custom Action action data problem - Advanced Installer Community
wgb_ks
Posts: 2
Joined: Wed Mar 30, 2022 8:54 pm

Custom Action action data problem

I am having a bit of a problem with a custom action in Advanced Installer (I am using version 19.3). I am using the "Launch Attached File" function to run a vb.script. The VB script needs the product version of the software installed. So far I have been unable to get the vb script to obtain the version number as defined in "Product Information -> Product Details -> Version" The vb script starts off with the following lines:

Code: Select all

Function set_hostname()

	Set wshShell = CreateObject( "WScript.Shell" )
	strComputerName = Session.Property("ProductVersion")
In Advanced Installer, I have the following parameters:
  • Attached File: PATH TO VB.SCRIPT
  • File Type: Visual Basic Script (.vbs)
  • Function: set_hostname
  • Action data: [|ProductVersion]
  • Execution Time: When the system is being modified (deferred)
  • Execution Options: Run under LocalSystem Account... AND Wait for custom action to finish before proceeding
  • Execution Stage Condition: Install
Any help would be appreciated
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom Action action data problem

Hello and welcome to our forums,

Please note that, in the "Action Data" field, you should pass the "ProductVersion" property as it follows:

Code: Select all

[ProductVersion]
not:

Code: Select all

[|ProductVersion]
Advanced Installer PseudoFormatted Type
The Advanced Installer PseudoFormatted data type is a string which can contain references to Properties. At build time the property references are replaced with the value of the respective properties.
The pipe character (vertical bar) "|" is part of the property referencing syntax and is mandatory.
Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
wgb_ks
Posts: 2
Joined: Wed Mar 30, 2022 8:54 pm

Re: Custom Action action data problem

Catlin,

Thank you for the help. While it might have helped, the problem is still not solved. I am still not getting the variable transferred correctly into the vb script. I tested my script by creating dummy data for the input. It worked. But if I try to get the variable name from Advance Installer, the script does not work.

If I use:

Code: Select all

Function set_hostname()

	Set wshShell = CreateObject( "WScript.Shell" )
	strComputerName = "THIS_IS_A_TEST_0.11.11"
	
I get the expected behavior.

If I use:

Code: Select all

Function set_hostname()

	Set wshShell = CreateObject( "WScript.Shell" )
	strComputerName = Session.Property("ProductVersion")

I do not get the expected behavior.
Hence, there may be two problems.
1. I am using the wrong syntax to access the variable or,
2. Advanced Installer is not sending me the correct data.

Let's start with my script. What do I need to add to my vb script to access the AI-supplied data?
Liviu
Posts: 1420
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Custom Action action data problem

Hello,

Can you please have a look on our tutorial here: How to access installer properties from deferred custom actions

The "Action Data" field represents the value of the CustomActionData property. This property can be retrieved as a regular property inside Deferred custom actions and it is available only for DLL, JScript and VBScript custom actions.

Deferred custom actions can receive information about the installation process, mostly only embedded in the CustomActionData property.

Therefore, as explained in our example from the first article, you need to use the "CustomActionData" property inside your script.

For example:

Code: Select all

dim strComputerName


Set wshShell = CreateObject( "WScript.Shell" )
strComputerName = Session.Property("CustomActionData") 
MsgBox strComputerName, 1, "test"

and the custom action is like this:
vbscript.png
vbscript.png (25.3 KiB) Viewed 2993 times

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 “Common Problems”