Frustrated with a simple if statement comparing versions

Got a problem you cannot solve? Try here.
Arthur
Posts: 12
Joined: Thu Sep 13, 2012 12:40 pm

Frustrated with a simple if statement comparing versions

Postby Arthur » Thu Jul 07, 2016 11:29 am

Hi,

I'm having an issue with an If statement when comparing version numbers. I have a very simple script for testing.

The version in my registry and the version to compare against is the same. In the If statement, I should be getting the MessageBox "No need to upgrade", but I am not.

Does anyone have any suggestions?

Code: Select all

Define Component: Native Setup
 
Set Variable VERSION_CHECK to 22.0.0.192
 
Read Registry Key HKLM\SOFTWARE\Macromedia\FlashPlayerActiveX\Version into VERSION_REGISTRY
 
MessageBox: , VERSION_CHECK: $VERSION_CHECK$$NEWLINE$$NEWLINE$VERSION_REGISTRY: $VERSION_REGISTRY$
 
if Variable VERSION_REGISTRY Greater Than (Version) $VERSION_CHECK$
 MessageBox: , No Need to upgrade
 else
 MessageBox: , Need to upgrade
end
 
Terminate Installation


Code: Select all

~InstallAware Clipboard Data~
~Terminate Install~
~{A696F45A-D7FE-4BEE-A223-1FB7A97B6DD1}~
~Comment~
~{6F68447A-7A2F-4D0A-B8EF-CFDFDF8B5795}~
~~
~End~
~{5E3307C7-5A25-4C50-BE9E-8A6A65C1A111}~
~MessageBox~
~{8CAEAE8E-AB27-47FD-9205-3EA1E0E8B5BB}~
~~
~Need to upgrade~
~0~
~2~
~~
~Else~
~{8A394F6E-0974-4547-857B-497BC14AFCEA}~
~MessageBox~
~{319F5974-8DA9-4FE5-8A29-CE993E3CA61D}~
~~
~No Need to upgrade~
~0~
~2~
~~
~If~
~{B5F34C3C-5B10-4720-AD32-B366090FC916}~
~VERSION_REGISTRY~
~6~
~$VERSION_CHECK$~
~FALSE~
~Comment~
~{451768FA-5291-488F-82E2-53D431C8AD99}~
~~
~MessageBox~
~{C9959FD0-C51B-45E4-B26C-184BCE45D97A}~
~~
~VERSION_CHECK: $VERSION_CHECK$$NEWLINE$$NEWLINE$VERSION_REGISTRY: $VERSION_REGISTRY$~
~0~
~1~
~~
~Comment~
~{E361AF78-8369-4D4E-B0AD-49779A77CF90}~
~~
~Read Registry~
~{35B10BAB-893B-4CF5-8CDE-00D66FC853D6}~
~VERSION_REGISTRY|~
~2~
~SOFTWARE\Macromedia\FlashPlayerActiveX~
~Version~
~Comment~
~{72A5A6A0-E228-4EAA-B6A4-5E0DBFF83FA9}~
~~
~Set Variable~
~{794D2D49-330E-4D42-B4FE-C5BB86475F2D}~
~VERSION_CHECK$MYAH$MYAH$FALSE~
~22.0.0.192~
~Comment~
~{EDC6C120-345B-4E84-AC6A-E9FEA8F70720}~
~~
~Define Component~
~{71C297CB-4ED6-4ED5-958C-131E0F2848A6}~
~Native Setup~
~TRUE~
~Description for #TITLE#~

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Frustrated with a simple if statement comparing versions

Postby FrancescoT » Thu Jul 07, 2016 12:18 pm

Dear Arthur,

I don't know which is the effective value returned by your registry key, but version comparing works fine.

Just tried this;

Code: Select all

~InstallAware Clipboard Data~
~Comment~
~{F4CA5CD5-EC21-4735-8D86-D1E8D86FC530}~
~~
~End~
~{94D29424-029E-4301-8BC9-118D3AC790D9}~
~MessageBox~
~{A9863DEA-09EB-42AD-AA2A-86259780B3CF}~
~~
~It's lower!~
~0~
~2~
~~
~Else~
~{4D5E5980-49B8-4A80-AE5A-97C9BA786D6B}~
~MessageBox~
~{A38CC4D1-6CFE-4101-B802-AED112AF097D}~
~~
~It's Greater!~
~0~
~2~
~~
~If~
~{481EBB9D-DA1C-4E0B-960A-4464659116E8}~
~LOWER_VALUE~
~6~
~$VERSION_CHECK$~
~FALSE~
~Comment~
~{10CF5227-0649-42E8-89DE-CAEA4C68EE03}~
~~
~End~
~{1DB8E0E7-6F10-4991-A7C7-67F117903E9C}~
~MessageBox~
~{6AB2DD45-31CB-4C57-ABA9-9F9B1BB9155D}~
~~
~Need to upgrade~
~0~
~2~
~~
~Else~
~{F9B496A9-E947-4426-B63E-322FC2A94034}~
~MessageBox~
~{A5C59003-D53F-4E77-BC3C-C6D190004495}~
~~
~It's Greater!~
~0~
~2~
~~
~If~
~{A7C581C3-1E63-4E10-ADF9-BA27625FAF85}~
~GREATER_VALUE~
~6~
~$VERSION_CHECK$~
~FALSE~
~Comment~
~{27F2F182-EDF5-4802-A815-50D1E3610490}~
~~
~MessageBox~
~{7F2A5339-0FBA-466A-B729-54923E82B443}~
~~
~VERSION_CHECK: $VERSION_CHECK$$NEWLINE$$NEWLINE$GREATER_VALUE: $GREATER_VALUE$$NEWLINE$$NEWLINE$LOWER_VALUE: $LOWER_VALUE$~
~0~
~1~
~~
~Comment~
~{BE8706B0-033D-4AF0-8A2E-3AAC721AFDD3}~
~~
~Set Variable~
~{943358FA-57C0-4DBD-BB38-2E3F2FE3A5E8}~
~LOWER_VALUE$MYAH$MYAH$FALSE~
~22.0.0.101~
~Set Variable~
~{41CC75E1-667E-4747-9E59-E5558C268F63}~
~GREATER_VALUE$MYAH$MYAH$FALSE~
~22.0.0.198~
~Set Variable~
~{A9C964A2-85DF-4E6D-862D-83D8C8B20272}~
~VERSION_CHECK$MYAH$MYAH$FALSE~
~22.0.0.192~


Code: Select all

Set Variable VERSION_CHECK to 22.0.0.192
Set Variable GREATER_VALUE to 22.0.0.198
Set Variable LOWER_VALUE to 22.0.0.101
 
MessageBox: , VERSION_CHECK: $VERSION_CHECK$$NEWLINE$$NEWLINE$GREATER_VALUE: $GREATER_VALUE$$NEWLINE$$NEWLINE$LOWER_VALUE: $LOWER_VALUE$
 
if Variable GREATER_VALUE Greater Than (Version) $VERSION_CHECK$
  MessageBox: , It's Greater!
  else
  MessageBox: , Need to upgrade
end
 
if Variable LOWER_VALUE Greater Than (Version) $VERSION_CHECK$
  MessageBox: , It's Greater!
  else
  MessageBox: , It's lower!
end

Hope this helps you.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

Arthur
Posts: 12
Joined: Thu Sep 13, 2012 12:40 pm

Re: Frustrated with a simple if statement comparing versions

Postby Arthur » Thu Jul 07, 2016 2:58 pm

Your example works for me also.

The difference is that I am reading the registry for a String value and storing in $VERSION_REGISTRY$ variable.

If you by chance have Adobe Flash Player ActiveX installed, can you also try reading the same registry key or another registry key that has a String value?

Is there something I need to do after reading a registry key that I am not doing?

Arthur
Posts: 12
Joined: Thu Sep 13, 2012 12:40 pm

Re: Frustrated with a simple if statement comparing versions

Postby Arthur » Thu Jul 07, 2016 3:06 pm

I think I know what is happening.

The $VERSION_CHECK$ Variable and the $VERSION_REGISTRY$ value is the same for me.

I modified yours where I made the $VERSION_CHECK$ and $GREATER_VALUE$ the same and had the same issue.

In this situation, the value might be less, equal, or greater. How should I best approach the script? Greater or equal do no thing. If is less than, upgrade?

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Frustrated with a simple if statement comparing versions

Postby FrancescoT » Fri Jul 08, 2016 9:51 am

Dear Arthur,

...maybe I am missing something, but if you only need to do "something" when a A value is less than B value, just evaluate this condition. If this is true then do something.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 184 guests