Sign in to follow this  
Followers 0
Djm79

RegRead Issue

11 posts in this topic

Hi,

I have a script that looks for a version number in a reg key, and if the value is less than or equal to this number the script than displays a warning message.

The problem I have is that when the key doesn't exist (before the software is installed) the script display the same warning as above.

$Inst2x = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\2x\AppServerClient", "ClientVersion")

if $inst2x <= "5.0.275" and inst2x = " " Then

msgbox(0,"error", version of 2x already installed)

Any ideas on how I can get round this would be great, thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$Inst2x = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\2x\AppServerClient", "ClientVersion")
if @error then Exit; or sleep(5000)
if $inst2x <= "5.0.275" and inst2x = " " Then
msgbox(0,"error", version of 2x already installed)

Edited by mrbond007

Share this post


Link to post
Share on other sites

Thanks for the reply MrBond007, but this doesn't do what I need.

I need to check the version number

($Inst2x = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\2x\AppServerClient", "ClientVersion")

if $inst2x <= "5.0.275" Then

and if this exists then the msg is displayed. This works fine.

What I need to add so a way of still running the install if the version number is available. At the moment if the inst2x key isn't available the warning box is still displayed as the <= is run. I need this to see that the key isn't they and then run the install.

I hope this makes sense

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the reply MrBond007, but this doesn't do what I need.

I need to check the version number

($Inst2x = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\2x\AppServerClient", "ClientVersion")

if $inst2x <= "5.0.275" Then

and if this exists then the msg is displayed. This works fine.

What I need to add so a way of still running the install if the version number is available. At the moment if the inst2x key isn't available the warning box is still displayed as the <= is run. I need this to see that the key isn't they and then run the install.

I hope this makes sense

dim $Inst2X
While 1
     $Inst2x = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\2x\AppServerClient", "ClientVersion")
     if @error <> 0 then
           ContinueLoop
           Sleep(1000)
     Else
           ExitLoop
     EndIf
WEnd
if $inst2x <= "5.0.275" and $inst2x = "" Then msgbox(0,"error", "version of 2x already installed")

Wait a minute look at this : msgbox(0,"error", version of 2x already installed)

it shoud be msgbox(0,"error", "version of 2x already installed")

Edited by mrbond007

Share this post


Link to post
Share on other sites

ERROR: 'Return' not allowed from global scope.

Share this post


Link to post
Share on other sites

dim $Inst2x

While 1

$Inst2x = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\2x\AppServerClient", "ClientVersion")

If @error <> O Then

ContinueLoop

Sleep(1000)

Else

ExitLoop

EndIf

WEnd

if $inst2x <= "5.0.275" and $inst2x = " " Then

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\2x")

RegDelete("HKEY_CURRENT_USER\SOFTWARE\2x")

msgbox(0,"Error","A version of the 2X Client has already been installed and configured, please remove this software using Add or Remove Programs from the control panel. Once removed please run this setup again.")

I get a syntax error on "if @error <> @ then

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

is it a zero or an O? try this... (didnt check code)

Dim $Inst2x

While 1
$Inst2x = RegRead("HKLM\SOFTWARE\2x\AppServerClient", "ClientVersion")
    If @error <> 0 Then
        ContinueLoop
        Sleep(1000)
    Else
        ExitLoop
    EndIf   
WEnd    

if $inst2x <= "5.0.275" and $inst2x = " " Then
RegDelete("HKLM\SOFTWARE\2x")
RegDelete("HKCU\SOFTWARE\2x")
msgbox(0,"Error","A version of the 2X Client has already been installed and configured, please remove this software using Add or Remove Programs from the control panel.  Once removed please run this setup again.")
EndIf
Edited by c4nm7

Share this post


Link to post
Share on other sites

Dim $Inst2x

While 1

$Inst2x = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\2x\AppServerClient", "ClientVersion")

If @error <> 0 Then

ContinueLoop

Sleep(1000)

Else

ExitLoop

EndIf

WEnd

if $inst2x <= "5.0.275" Then

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\2x")

RegDelete("HKEY_CURRENT_USER\SOFTWARE\2x")

msgbox(0,"Error","A version of the 2X Client has already been installed and configured, please remove this software using Add or Remove Programs from the control panel. Once removed please run this setup again.")

EndIf

Didn't do anything I'm afraid !!!!!

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

returning on the first post:

Dim $Inst2x

$Inst2x = RegRead("HKLM\SOFTWARE\2x\AppServerClient", "ClientVersion")
if @error then
Msgbox(16, "Error", "Key not found")
Elseif $inst2x <= "5.0.275" and $inst2x = " " then
RegDelete("HKLM\SOFTWARE\2x")
RegDelete("HKCU\SOFTWARE\2x")
msgbox(16,"Error","A version of the 2X Client has already been installed and configured, please remove this software using Add or Remove Programs from the control panel.  Once removed please run this setup again.")
EndIf
Exit

i dont-didnt test it and i cannot be sure about the RegDelete()

PS:also check this:$inst2x <= "5.0.275" and inst2x = " ", seems strange to me, im not sure but this might be better: $inst2x <= "5.0.275" Or inst2x == " "...dont understand why do you use " "

Edited by c4nm7

Share this post


Link to post
Share on other sites

You may have better logic with breaking up the version number.

Example:

$Inst2x = "5.0.275"

Global $UpToDate
$Inst2x = RegRead("HKLM\SOFTWARE\2x\AppServerClient", "ClientVersion")
If @error Then
    MsgBox(0x40030, '', 'Unable to read from registry. Perhaps not installed')
ElseIf $Inst2x <> "" Then
    ; Version required
    Global $Version[4] = [4, 5, 0, 275]; 4 is for index use only
    ;
    ; Split RegRead into parts for comparison
    $RegVersion = StringSplit($Inst2x, '.')
    ;
    If $RegVersion[0] > 2 And $RegVersion[0] <= 4 Then
        ; Check parted version numbers
        If Int($RegVersion[1]) < $Version[1] Then
            $UpToDate = False
        ElseIf Int($RegVersion[2]) < $Version[2] Then
            $UpToDate = False
        ElseIf Int($RegVersion[3]) < $Version[3] Then
            $UpToDate = False
        Else
            $UpToDate = True
        EndIf
    EndIf
EndIf

If Not $UpToDate Then
    ; Install
EndIf

:)

Share this post


Link to post
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
Sign in to follow this  
Followers 0