nsis安装mysql服务语句_NSIS——检测SQL Server安装版本

该博客介绍了一个使用NSIS脚本检测SQL Server安装版本的方法,确保安装的产品需要的是v8.00.534(SQL Server 2000 SP2或更高版本)。如果检测到的版本不符合要求,安装程序将提示用户并中止安装。
摘要由CSDN通过智能技术生成

Function StrTok

Exch $R1

Exch 1

Exch $R0

Push $R2

Push $R3

Push $R4

Push $R5

;R0 fullstring

;R1 tokens

;R2 len of fullstring

;R3 len of tokens

;R4 char from string

;R5 testchar

StrLen $R2 $R0

IntOp $R2 $R2 + 1

loop1:

IntOp $R2 $R2 - 1

IntCmp $R2 0 exit

StrCpy $R4 $R0 1 -$R2

StrLen $R3 $R1

IntOp $R3 $R3 + 1

loop2:

IntOp $R3 $R3 - 1

IntCmp $R3 0 loop1

StrCpy $R5 $R1 1 -$R3

StrCmp $R4 $R5 Found

Goto loop2

Goto loop1

exit:

;Not found!!!

StrCpy $R1 ""

StrCpy $R0 ""

Goto Cleanup

Found:

StrLen $R3 $R0

IntOp $R3 $R3 - $R2

StrCpy $R1 $R0 $R3

IntOp $R2 $R2 - 1

IntOp $R3 $R3 + 1

StrCpy $R0 $R0 $R2 $R3

Cleanup:

Pop $R5

Pop $R4

Pop $R3

Pop $R2

Exch $R0

Exch 1

Exch $R1

FunctionEnd

;--------------------------------

; CheckMinSQLVersion

;

; Written by Matthew Kershaw (matthew.kershaw@us.didata.com)

;

; For this function the min SQL version must be SQL2kSP2 ...

; typically the SQLServer version is located in

; HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion\CurrentVersion

; but for SPs, the new version is located in

; HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion\CSDVersion.

; For SP2, the value is 8.00.534. If the CSDVersion key does not exist,

; no SP has been installed.

Function CheckMinSQLVersion

ClearErrors

ReadRegStr $0 HKLM "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion" "CurrentVersion"

IfErrors SQLServerNotFound SQLServerFound

SQLServerFound:

ReadRegStr $4 HKLM "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion" "CSDVersion"

IfErrors SPNotFound SPFound

SPFound:

;Check the first digit of the version; must be 8

StrCpy $0 $4

StrCpy $1 $0 1

StrCmp $1 "8" SQLServer2000Found SQLServerVersionError

Goto ExitCheckMinSQLVersion

SQLServer2000Found:

Push $0

Push "."

Call StrTok;For an example string of "8.00.194", "8" and "00.194" now on stack

Pop $2

Push "."

Call StrTok;"00" and "194" now on stack

Pop $2

Pop $3

IntCmp $3 534 0 SQLServerVersionError 0

Push 1

Goto ExitCheckMinSQLVersion

SQLServerVersionError:

MessageBox MB_OK|MB_ICONEXCLAMATION "此产品需要SQLServer的最低版本为 v8.00.534 (SQLServer 2000, SP2);检测到当前版本为$0。安装程序将中止。"

Push 0

Goto ExitCheckMinSQLVersion

SQLServerNotFound:

MessageBox MB_OK|MB_ICONEXCLAMATION "安装程序未能检测到Microsoft SQLServer,这是必须安装的。安装程序将中止。"

Push 0

Goto ExitCheckMinSQLVersion

SPNotFound:

MessageBox MB_OK|MB_ICONEXCLAMATION "MicrosfotSQLServer v $0 已安装。SQLServer 2000 SP2 (or later)必须安装。安装程序将中止。"

Push 0

Goto ExitCheckMinSQLVersion

ExitCheckMinSQLVersion:

FunctionEnd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值