Jump to content

Conditional statement on Registry value


GregP
 Share

Recommended Posts

Here goes another dumb newbie question -

I am trying to check for the version of an application installed on a workstation by using the RegRead command. The conditional statement following the RegRead command is not working as expected ......

===============================================

$HFM = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Hyperion Solutions\Hyperion Financial Management\Install","VERSION")

MsgBox(32,"DEBUG","The value of $HFM is " & $HFM)

;;;;;; ;;;; The value returned in the msgbox is 3.5.0.0.384 ;;;;;;;;;;;;;;;;;;;;;;;;

IF $HFM = "3.5.0.0.384" Then

MsgBox(32,"DEBUG","The value of $HFM is" & $HFM)

=====================================================

The conditional statement fails with the "=" if I change it to "<>" the conditional statement works? What am I doing wrong :whistle: ?

Thanks,

Greg

Link to comment
Share on other sites

Here goes another dumb newbie question -

I am trying to check for the version of an application installed on a workstation by using the RegRead command.  The conditional statement following the RegRead command is not working as expected ......

===============================================

$HFM = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Hyperion Solutions\Hyperion Financial Management\Install","VERSION")

MsgBox(32,"DEBUG","The value of $HFM is " & $HFM)

;;;;;; ;;;; The value returned in the msgbox is 3.5.0.0.384 ;;;;;;;;;;;;;;;;;;;;;;;;

IF $HFM = "3.5.0.0.384" Then

MsgBox(32,"DEBUG","The value of $HFM is" & $HFM)

=====================================================

The conditional statement fails with the "=" if I change it to "<>" the conditional statement works?  What am I doing wrong  :whistle: ?

Thanks,

Greg

<{POST_SNAPBACK}>

it's possible that you're missing a character (a space etc) when taking the value from the messagebox. another thing you could do is:

$HFM = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Hyperion Solutions\Hyperion Financial Management\Install","VERSION")
ClipPut($hfm)

execute that as a script by itself, then paste the value between double quotes as your value to compare $HFM to.

Link to comment
Share on other sites

it's possible that you're missing a character (a space etc) when taking the value from the messagebox.  another thing you could do is:

$HFM = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Hyperion Solutions\Hyperion Financial Management\Install","VERSION")
ClipPut($hfm)

execute that as a script by itself, then paste the value between double quotes as your value to compare $HFM to.

<{POST_SNAPBACK}>

You are good .... there was a space at the end that wasn't appearing in the msgbox -

I changed the code to:

MsgBox(32,"DEBUG","The value of $HFM is" & $HFM & "A")

and was able to see the space.

Thanks for your help!

:whistle:

Link to comment
Share on other sites

Here goes another dumb newbie question -

I am trying to check for the version of an application installed on a workstation by using the RegRead command.  The conditional statement following the RegRead command is not working as expected ......

===============================================

$HFM = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Hyperion Solutions\Hyperion Financial Management\Install","VERSION")

MsgBox(32,"DEBUG","The value of $HFM is " & $HFM)

;;;;;; ;;;; The value returned in the msgbox is 3.5.0.0.384 ;;;;;;;;;;;;;;;;;;;;;;;;

IF $HFM = "3.5.0.0.384" Then

MsgBox(32,"DEBUG","The value of $HFM is" & $HFM)

=====================================================

The conditional statement fails with the "=" if I change it to "<>" the conditional statement works?  What am I doing wrong  :whistle: ?

Thanks,

Greg

<{POST_SNAPBACK}>

Another function that you can use is StringStripWS("String", 3) The number 3 tell the function to remove all space at the front and end of the string.

$HFM = StringStripWS(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Hyperion Solutions\Hyperion Financial Management\Install","VERSION"), 3)

IF $HFM = "3.5.0.0.384" Then

MsgBox(32,"DEBUG","The value of $HFM is" & $HFM)

I think this way is better because if one of the computer that you are running the script doesn't have the space at the end then your script won't know if is the right installation or not

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Another function that you can use is StringStripWS("String", 3) The number 3 tell the function to remove all space at the front and end of the string.

$HFM = StringStripWS(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Hyperion Solutions\Hyperion Financial Management\Install","VERSION"), 3)

IF $HFM = "3.5.0.0.384" Then

MsgBox(32,"DEBUG","The value of $HFM is" & $HFM)

I think this way is better because if one of the computer that you are running the script doesn't have the space at the end then your script won't know if is the right installation or not

<{POST_SNAPBACK}>

actually, because the version number placed in registry by the installer, then all installs of the same version should have the same value (space included). and any other version doesn't meet the condition, regardless of the space or not...of course you could create hypothetical situations where it's a different build of the same version where they modified that, but didn't increment the build number in the version declaration in the registry you could end up with a false condition fail. To that i'd say that even if they didn't increment the build number, it's technically not the same product and the condition should fail.
Link to comment
Share on other sites

Taking advantage of the StringInStr() function would prevent spaces in the string from being a problem, and you could also do nifty things like disregard subversions using this trick.

; if version is of the 3.5.0.0 branch:
if stringInStr($hfm, "3.5.0.0.") then

; if version is of the 3.5 branch:
if stringInStr($hfm, "3.5.") then
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...