VMware Cloud Community
MarkStr
Contributor
Contributor

InstallBuilder Updating $installdir with Regex Expression

<setInstallerVariableFromRegEx>
    <name>shortinstall</name>
    <pattern>^Job:(.*)$</pattern>
    <substitution>\1</substitution>
    <text>${installdir}</text>
    <ruleList>
     <platformTest>
      <type>windows-x64<type>
     </rulelist>
</setInstallerVariableFromRegEx>

Hi All,

I am not really a programmer more a scripting person. I am trying to grab a shortened version of the system variable that is set to "c:\Program Files\JobBag" The JobBag portion can be changed by the user at run time. Using the above never resets the variable back to JobBag. Any help appreciated.

Reply
0 Kudos
2 Replies
michieldhont_
Hot Shot
Hot Shot

Hi @MarkStr,

You could just set the installdir variable directly:

 

<setInstallerVariable>
   <name>installdir</name>
   <value>${platform_install_prefix}/${product_shortname}/${user_input}</value>
</setInstallerVariable>

 

Would that work for you?

Regards,

Michiel

Reply
0 Kudos
MarkStr
Contributor
Contributor

<setInstallerVariableFromRegEx>
<name>short</name>
<pattern>^(.*?)\\(.*?)\\(.*?)$</pattern>
<substitution>\3</substitution>
<text>${installdir}</text>
</setInstallerVariableFromRegEx>

Hi All, Just wanted to give back to the community. I did find a solution in the end. It was a modified example from the Installbuilder documentation. It was not what I wanted exactly but it did do the Job. The above example did update my variable correctly as long as the program was installed in one sub-directory and no more based on my pattern. Most users would have installed our application into the "program files" directory so the script will probably work with at least 95% of our installs. I will just have to deal manually with 5% that had unusual installation directories.

Reply
0 Kudos