How to check whether a string contains a substring in installshield

207 Views Asked by At

I am having a following string like,

C:\program files(x86)\MySoftware\Version10.0\bin
C:\program files(x86)\MySoftware\Version20.0\bin
C:\program files(x86)\MySoftware\Version30.0\bin

The version number is random and will vary each time. I cannot use to find a substring with just 'C:\program files(x86)\MySoftware'. I need a to somehow search a substring like 'C:\program files(x86)\MySoftware<someversion>\bin'

How to achieve that in InstallScript?

1

There are 1 best solutions below

2
On

You need to use regular expressions to match the given paths in installscript. For defining match pattern, refer this link - https://www.tutorialspoint.com/vbscript/vbscript_reg_expressions.htm

Here is the sample code:

OBJECT oRegEx, oMatch;
NUMBER nRet;
begin

//try to create the RegEx object
try
set oRegEx = CreateObject("VBScript.RegExp");
catch
MessageBox("CreateObject Failed- "+ Err.Decription, SEVERE);
endcatch;

oRegEx.Pattern = szPattern;
oRegEx.Global = 1; //set to 1 to find all matches in the string
//set to 0 to find only the first match
try
set oMatch = oRegEx.Execute(szString);
catch
MessageBox("CreateObject Failed- "+ Err.Decription, SEVERE);
endcatch;

nRet = oMatch.Count;

return nRet;
end;