Coal Honeywell
Posts: 2
Joined: Mon Jul 02, 2018 9:51 pm

How to lookup/store the install location of software installed as prereq

Mon Jul 02, 2018 10:22 pm

Our installer is setup to install Tomcat if it's not present as one of the Prerequisites in our project. The Tomcat installation creates a registry entry for the install location. We deploy our web application on top of this and we need to update the web apps context.xml as part of this (which requires us to know where Tomcat was installed).

We previously had the Search option to lookup the registry entry but that appears to run before the prerequisites are installed and so is not accurate after the install. In looking at the forums it appears that other have created a custom action to lookup the registry entry and store it in a AI parameter.

In trying to do this I've played around with the PowerShellScriptInline and PowerShellScriptFile. I'm just not sure how to assign this to a parameter in the Advanced Installer that I can use. Here are the two problems I've seen (PS- I'm not a DOS command line programmer)

1) The script I created will run and output what I want from a DOS or Powershell command line but fails when I try to run it from the Advanced Installer. Here is the single line in the script:
FOR /F "usebackq tokens=2,* skip=2" %%L IN (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Tomcat\9.0\Tomcat9" /v InstallPath`) DO echo %%M

When I run the script using the Test button in the PowerShellScriptFile custom action I get the following:
Return code: 574

Script output: "ERROR: Missing opening '(' after keyword 'for'."


2) Assuming I can get the script running I want to store the return value from in a AI property that I can use in other custom scripts. I tried doing this by creating a

# Block for declaring the script parameters.
Param()

AI_SetMsiProperty MY_PROP Start-Process -FilePath "C:\InstallerTest\getTomcatHome2.bat"

But this only succeeds in setting the MY_PROP to the value "Start-Process"


Any help you can offer OR a new way to do what I'm trying would be great.

Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: How to lookup/store the install location of software installed as prereq

Thu Jul 05, 2018 1:56 pm

Hi,

In order to install a prerequisite before the searches execution you can add them as "pre-install" prerequisites.

1. I tested the PowerShell script that you posted outside Advanced Installer (in a PowerShell Window), but I got the same error that you mentioned ("ERROR: Missing opening '(' after keyword 'for'."). In order to execute a script in Advanced Installer, please firs make sure that it works outside.

2. Indeed, in order to set a property from a PowerShell script you can use the "AI_SetMsiProperty" predefined function, however I'm afraid that it only accepts strings or other properties, not the result of some scripts execution.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”