This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- How to compare product versions during installation
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 20, 2008
09:18 PM
How to compare product versions during installation
HI all,
I have a question.
I am developing an installation of our product, I put the product version to the windows registry. For the next installation, I will read the version from registry and compare with the current version I want to install.
How can I know that it is older or newer since I cannot find any comparation action or rule that support "<" or ">".
can I perform this without customer code?
thanks.
I have a question.
I am developing an installation of our product, I put the product version to the windows registry. For the next installation, I will read the version from registry and compare with the current version I want to install.
How can I know that it is older or newer since I cannot find any comparation action or rule that support "<" or ">".
can I perform this without customer code?
thanks.
(7) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 21, 2008
09:54 AM
The Find Component in [InstallAnywhere] Registry action supports version comparisons, so if you can base your decision on an installed IA component, that might work. Offhand I'm not aware of a built-in version-compare operator for the Windows registry, however.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 25, 2008
04:27 AM
thanks Robert,
I have tried your suggestion, however, Find Component in [InstallAnywhere] Registry action can only find component with UUID. unfortunately, none the component I am going to packed into the installer have a UUID.
thank you anyway..
I have tried your suggestion, however, Find Component in [InstallAnywhere] Registry action can only find component with UUID. unfortunately, none the component I am going to packed into the installer have a UUID.
thank you anyway..
RobertDickau wrote:
The Find Component in [InstallAnywhere] Registry action supports version comparisons, so if you can base your decision on an installed IA component, that might work. Offhand I'm not aware of a built-in version-compare operator for the Windows registry, however.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 25, 2008
02:53 PM
pl take a look at
http://helpnet.macrovision.com/robo/projects/installshieldmp11-5apis/com/installshield/product/SoftwareObjectKey.html#SoftwareObjectKey()
and SoftwareVersion class also.
http://helpnet.macrovision.com/robo/projects/installshieldmp11-5apis/com/installshield/product/SoftwareObjectKey.html#SoftwareObjectKey()
and SoftwareVersion class also.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 25, 2008
03:20 PM
the below is the answer i got from IA, which i have not looked at it yet.
pl send me the script to update the version in the .iap_xml without opening in IDE
http://knowledge.macrovision.com/selfservice/microsites/microsite.do?msid=MS_INSTALLATION_1_1
and search for "Q112140" in order to view the Knowledge Base article. In order to compare the versions, you can use the Number Comparison Rule available for download on our website, http://www.macrovision.com/downloads.htm, under InstallAnywhere > Files and Utilities > Custom Code. There is a readme file that explains how to use the Rule. You can then compare the value of $PRODUCT_VERSION_NUMBER$ with the value returned by the Find Component in Registry action
pl send me the script to update the version in the .iap_xml without opening in IDE
http://knowledge.macrovision.com/selfservice/microsites/microsite.do?msid=MS_INSTALLATION_1_1
and search for "Q112140" in order to view the Knowledge Base article. In order to compare the versions, you can use the Number Comparison Rule available for download on our website, http://www.macrovision.com/downloads.htm, under InstallAnywhere > Files and Utilities > Custom Code. There is a readme file that explains how to use the Rule. You can then compare the value of $PRODUCT_VERSION_NUMBER$ with the value returned by the Find Component in Registry action
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 25, 2008
04:32 PM
the number comparison is not helpful as it clearly says that it has to be interger, double or float..
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 26, 2008
02:18 PM
The following might be one approach to comparing version strings. (No guarantees---it worked once on one system as a messing-around-during-coffee-break test---but it might be useful for the general idea...)
[code]//
// CompareVersionAction: compares two version strings of the format 1.2.3,
// taken from properties $VERSION_A$ and $VERSION_B$, returning
// result in $VERSION_COMPARE_RESULT$, which can then be used in
// a rule, for example. $VERSION_COMPARE_RESULT$ will be 1 if Version A
// is greater, -1 if Version B is greater, and 0 if they're equal.
//
// Nonnumeric fields (such as "a" in 1.2.a) are treated as zero.
//
// To compile, run:
// javac -classpath ...\IA\IAClasses.zip CompareVersionAction.java
//
// To package as an action, run:
// jar cvf CompareVersionAction.jar CompareVersionAction.class
//
// Afterward, can use in an Execute Custom Code action.
//
// TODO:
// * generalize not to use hard-coded variable names
// * show error for empty VERSION_A and VERSION_B values
// * write steps to debug log file
// * handle semi-numeric fields such as "2a" better
// * need to handle negative fields differently? currently 1.-2.3 goes through
//
import com.zerog.ia.api.pub.*;
public class CompareVersionAction extends CustomCodeAction
{
public void install(InstallerProxy ip)
{
// read the two properties, split at dots
String versionA = ip.substitute("$VERSION_A$");
String versionB = ip.substitute("$VERSION_B$");
String[] versionAPieces = versionA.split("\\.");
String[] versionBPieces = versionB.split("\\.");
// assume they're equal, try to disprove this later
String result = "0";
int longerLength =
Math.max(versionAPieces.length, versionBPieces.length);
for (int i = 0; i < longerLength; i++)
{
int versionAField = 0;
int versionBField = 0;
try
{
versionAField = Integer.parseInt(versionAPieces);
} // non-numeric or missing field assumed to be zero
catch(NumberFormatException nan) { versionAField = 0; }
catch(ArrayIndexOutOfBoundsException oob) { versionAField = 0; }
try
{
versionBField = Integer.parseInt(versionBPieces);
}
catch(NumberFormatException nan) { versionBField = 0; }
catch(ArrayIndexOutOfBoundsException oob) { versionBField = 0; }
if (versionAField > versionBField)
{
result = "1";
break;
}
if (versionAField < versionBField)
{
result = "-1";
break;
}
}
ip.setVariable("$VERSION_COMPARE_RESULT$", result);
}
public String getInstallStatusMessage( ) { return "..."; }
public void uninstall(UninstallerProxy up) { /* do nothing on uninstall*/ }
public String getUninstallStatusMessage( ) { return "..."; }
}[/code]
[code]//
// CompareVersionAction: compares two version strings of the format 1.2.3,
// taken from properties $VERSION_A$ and $VERSION_B$, returning
// result in $VERSION_COMPARE_RESULT$, which can then be used in
// a rule, for example. $VERSION_COMPARE_RESULT$ will be 1 if Version A
// is greater, -1 if Version B is greater, and 0 if they're equal.
//
// Nonnumeric fields (such as "a" in 1.2.a) are treated as zero.
//
// To compile, run:
// javac -classpath ...\IA\IAClasses.zip CompareVersionAction.java
//
// To package as an action, run:
// jar cvf CompareVersionAction.jar CompareVersionAction.class
//
// Afterward, can use in an Execute Custom Code action.
//
// TODO:
// * generalize not to use hard-coded variable names
// * show error for empty VERSION_A and VERSION_B values
// * write steps to debug log file
// * handle semi-numeric fields such as "2a" better
// * need to handle negative fields differently? currently 1.-2.3 goes through
//
import com.zerog.ia.api.pub.*;
public class CompareVersionAction extends CustomCodeAction
{
public void install(InstallerProxy ip)
{
// read the two properties, split at dots
String versionA = ip.substitute("$VERSION_A$");
String versionB = ip.substitute("$VERSION_B$");
String[] versionAPieces = versionA.split("\\.");
String[] versionBPieces = versionB.split("\\.");
// assume they're equal, try to disprove this later
String result = "0";
int longerLength =
Math.max(versionAPieces.length, versionBPieces.length);
for (int i = 0; i < longerLength; i++)
{
int versionAField = 0;
int versionBField = 0;
try
{
versionAField = Integer.parseInt(versionAPieces);
} // non-numeric or missing field assumed to be zero
catch(NumberFormatException nan) { versionAField = 0; }
catch(ArrayIndexOutOfBoundsException oob) { versionAField = 0; }
try
{
versionBField = Integer.parseInt(versionBPieces);
}
catch(NumberFormatException nan) { versionBField = 0; }
catch(ArrayIndexOutOfBoundsException oob) { versionBField = 0; }
if (versionAField > versionBField)
{
result = "1";
break;
}
if (versionAField < versionBField)
{
result = "-1";
break;
}
}
ip.setVariable("$VERSION_COMPARE_RESULT$", result);
}
public String getInstallStatusMessage( ) { return "..."; }
public void uninstall(UninstallerProxy up) { /* do nothing on uninstall*/ }
public String getUninstallStatusMessage( ) { return "..."; }
}[/code]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 31, 2008
02:35 AM
thanks a lot, I still have a concern. is there any license issue of using those code in a commercial software product. since I have buy IA license, do i need separated license for those customer code?
thank you.
thank you.
RobertDickau wrote:
The following might be one approach to comparing version strings. (No guarantees---it worked once on one system as a messing-around-during-coffee-break test---but it might be useful for the general idea...)
[code]//
// CompareVersionAction: compares two version strings of the format 1.2.3,
// taken from properties $VERSION_A$ and $VERSION_B$, returning
// result in $VERSION_COMPARE_RESULT$, which can then be used in
// a rule, for example. $VERSION_COMPARE_RESULT$ will be 1 if Version A
// is greater, -1 if Version B is greater, and 0 if they're equal.
//
// Nonnumeric fields (such as "a" in 1.2.a) are treated as zero.
//
// To compile, run:
// javac -classpath ...\IA\IAClasses.zip CompareVersionAction.java
//
// To package as an action, run:
// jar cvf CompareVersionAction.jar CompareVersionAction.class
//
// Afterward, can use in an Execute Custom Code action.
//
// TODO:
// * generalize not to use hard-coded variable names
// * show error for empty VERSION_A and VERSION_B values
// * write steps to debug log file
// * handle semi-numeric fields such as "2a" better
// * need to handle negative fields differently? currently 1.-2.3 goes through
//
import com.zerog.ia.api.pub.*;
public class CompareVersionAction extends CustomCodeAction
{
public void install(InstallerProxy ip)
{
// read the two properties, split at dots
String versionA = ip.substitute("$VERSION_A$");
String versionB = ip.substitute("$VERSION_B$");
String[] versionAPieces = versionA.split("\\.");
String[] versionBPieces = versionB.split("\\.");
// assume they're equal, try to disprove this later
String result = "0";
int longerLength =
Math.max(versionAPieces.length, versionBPieces.length);
for (int i = 0; i < longerLength; i++)
{
int versionAField = 0;
int versionBField = 0;
try
{
versionAField = Integer.parseInt(versionAPieces);
} // non-numeric or missing field assumed to be zero
catch(NumberFormatException nan) { versionAField = 0; }
catch(ArrayIndexOutOfBoundsException oob) { versionAField = 0; }
try
{
versionBField = Integer.parseInt(versionBPieces);
}
catch(NumberFormatException nan) { versionBField = 0; }
catch(ArrayIndexOutOfBoundsException oob) { versionBField = 0; }
if (versionAField > versionBField)
{
result = "1";
break;
}
if (versionAField < versionBField)
{
result = "-1";
break;
}
}
ip.setVariable("$VERSION_COMPARE_RESULT$", result);
}
public String getInstallStatusMessage( ) { return "..."; }
public void uninstall(UninstallerProxy up) { /* do nothing on uninstall*/ }
public String getUninstallStatusMessage( ) { return "..."; }
}[/code]
![](/skins/images/8CE4FAD0DE6F3A6F9D0567434D2D2DAE/responsive_peak/images/icon_anonymous_message.png)