在NSIS脚本内加入对.net framework和MDAC版本的判断

首先到 NSIS官网上下载一个插件,名:XtInfoPlugin.zip,链接地址:http://nsis.sourceforge.net/mediawiki/images/d/de/XtInfoPlugin.zip
将插件:xtInfoPlugin.dll复制到NSIS安装目录..\NSIS\Plugins下
在脚本内添加一句
如:!addplugindir "C:\Program Files\NSIS\Plugins"
然后在Funtion.onInit内
;判断DotNetFramework 1.1是否已经 安装
xtInfoPlugin::IsDotNetFrameworkInstalled
Pop $0
${if} $0 == true
xtInfoPlugin::GetDotNetFrameworkId
; GetDotNetFrameworkId (id methods) return x.x and not build info
Pop $0
${if} $0 != "1.1"
Messagebox MB_OK "系统检测到您计算机上的DotNetFramework版本低于1.1,点击[确定]安装"
EXECWAIT '"$PLUGINSDIR\dotnetfx_cn.exe"'
;!insertmacro DetailText "正在安装.net framework 1.1组件"
${endif}
${else}
Messagebox MB_OK "系统检测到您计算机上没有安装DotNetFramework1.1,点击[确定]安装"
EXECWAIT '"$PLUGINSDIR\dotnetfx_cn.exe"'
;!insertmacro DetailText "正在安装.net framework 1.1组件"
${endif}

;判断 MDAC当前版本
Strcpy $2 "2.7"
Push $2
xtInfoPlugin::GetMDACVersion
Pop $1
Push $1
xtInfoPlugin::CompareVersion
Pop $0
${if} $0 < 0
EXECWAIT '"$PLUGINSDIR\mdac_typ.exe"'
MessageBox MB_OK "MDAC version is OLDER than $2 (found: $1)"
${else}
MessageBox MB_OK "MDAC version is NEWER than $2 (found: $1)"
${endif}
over
其实在XtInfoPlugin.zip压缩包内有Example的

你可能感兴趣的:(framework)