Old 12th May 2017, 12:59   #1
jpps
Junior Member
 
Join Date: May 2017
Posts: 2
ReadRegStr seems to be pulling old values

I have a function that is checking for the minimum versions of MSSQLExpress installed on a server. When i test the installer with a version lower than the required versions the code works and errors out with my expected message. When i upgrade MSSQLExpress to the required version or above it will still act like it's reading the original version number and continue to error out. I have checked the registry key that it's looking for and it's updating with the correct value but my installer is still coming back with the older version number. This behavior persists through reboots as well.


Here is the section of code that has the logic. Everything else is just Messages for the user.

code:

ClearErrors
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Microsoft SQL Server\SQLEXPRESS\MSSQLServer\CurrentVersion" "CurrentVersion"
IfErrors SQLServerNotFound SQLServerFound1

SQLServerFound1:
StrCpy $1 $0 2
StrCmp $1 "10" SQLServer2008Found SQLServerFound2
SQLServerFound2:
StrCpy $1 $0 2
StrCmp $1 "11" SQLServer2012Found SQLServerVersionError

SQLServer2008Found:

Push $0
Push "."
Call StrTok ;For an example string of "10.50.6000", "10" and "50.6000" now on stack
Pop $2
Push "."
Call StrTok ;"50" and "6000" now on stack
Pop $2
Pop $3

${VersionCompare} $3 6000 $R0
${If} $R0 == "0"
Goto ExitCheckMinSQLVersionNonAbort
${ElseIf} $R0 == "1"
Goto ExitCheckMinSQLVersionNonAbort
${ElseIf} $R0 == "2"
!ifndef SQLVersion
!define SQLVersion "SQLServer 2008 R2 version of SP3 10.50.6000"
!endif
Goto SQLServerVersionError
${EndIf}
Goto ExitCheckMinSQLVersionNonAbort

SQLServer2012Found:

Push $0
Push "."
Call StrTok ;For an example string of "11.0.6020", "11" and "0.6020" now on stack
Pop $2
Push "."
Call StrTok ;"0" and "6020" now on stack
Pop $2
Pop $3

${VersionCompare} $3 2100 $R0
${If} $R0 == "0"
Goto ExitCheckMinSQLVersionNonAbort
${ElseIf} $R0 == "1"
Goto ExitCheckMinSQLVersionNonAbort
${ElseIf} $R0 == "2"
!ifndef SQLVersion
!define SQLVersion "SQLServer 2012 Version of SP3 11.0.6020"
!endif
Goto SQLServerVersionError
${EndIf}
Goto ExitCheckMinSQLVersionNonAbort

jpps is offline   Reply With Quote
Old 12th May 2017, 22:52   #2
jpps
Junior Member
 
Join Date: May 2017
Posts: 2
Here's a little clearer example of what's happening. Lets say I have MSSQLExpress version 10.50.4000 installed. So I run this command and it will come back with that version string.


code:
ReadRegStr $1 HKLM "SOFTWARE\Microsoft\Microsoft SQL Server\SQLEXPRESS\MSSQLServer\CurrentVersion" "CurrentVersion"



But, then I install SP3 which brings the version number in the registry up to 10.50.6000. The same exact command that worked before looking at the same registry key that has updated if you look at it in regedit, still shows the old version number.

I don't really understand why it's still showing the old version number when you can look in regedit and see that the version has updated?
jpps is offline   Reply With Quote
Old 13th May 2017, 09:50   #3
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 843
Perhaps it's a 32bit/64bit issue. Try switching the registry view to 64bit, read from the registry, and set it back to 32bit. Reference:http://nsis.sourceforge.net/Docs/Cha...tml#setregview.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump