NSIS检测.NET Framework并在线下载

Section -.NET Framework
;检测是否是需要的.NET Framework版本
Call GetNetFrameworkVersion
Pop $R1
;${If} $R1 < '2.0.50727'
;${If} $R1 < '3.5.30729.4926'
${If} $R1 < '4.0.30319'
;${If} $R1 < '4.5.52747'
MessageBox MB_YESNO|MB_ICONQUESTION "此软件运行需要.NET Framework 4.0运行环境,但您机器上似乎没有安装此环境。$\r$\n您有两个选择:$\r$\n1.您自己到互联网上下载.NET Framework 4.0安装,然后再运行此软件$\r$\n2.使用此安装程序在线下载并安装.NET Framework 4.0$\r$\n$\r$\n现在在线下载并安装.NET Framework 4.0,请确认您的机器已连接互联网.继续吗?" IDNO +
Call DownloadNetFramework4
${ENDIF}
SectionEnd Function GetNetFrameworkVersion
;获取.Net Framework版本支持
Push $
Push $
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Install"
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Version"
StrCmp $ KnowNetFrameworkVersion +
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" "Install"
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" "Version"
StrCmp $ KnowNetFrameworkVersion +
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup" "InstallSuccess"
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup" "Version"
StrCmp $ KnowNetFrameworkVersion +
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727" "Install"
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727" "Version"
StrCmp $ "" + +
StrCpy $ "2.0.50727.832"
StrCmp $ KnowNetFrameworkVersion +
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322" "Install"
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322" "Version"
StrCmp $ "" + +
StrCpy $ "1.1.4322.573"
StrCmp $ KnowNetFrameworkVersion +
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\.NETFramework\policy\v1.0" "Install"
ReadRegDWORD $ HKLM "SOFTWARE\Microsoft\.NETFramework\policy\v1.0" "Version"
StrCmp $ "" + +
StrCpy $ "1.0.3705.0"
StrCmp $ KnowNetFrameworkVersion +
StrCpy $ "not .NetFramework"
KnowNetFrameworkVersion:
Pop $
Exch $
FunctionEnd Function DownloadNetFramework2
;下载 .NET Framework 2.0 SP2
NSISdl::download /TRANSLATE2 '正在下载 %s' '正在连接...' '(剩余 1 秒)' '(剩余 1 分钟)' '(剩余 1 小时)' '(剩余 %u 秒)' '(剩余 %u 分钟)' '(剩余 %u 小时)' '已完成:%skB(%d%%) 大小:%skB 速度:%u.%01ukB/s' /TIMEOUT= /NOIEPROXY 'http://download.microsoft.com/download/c/6/e/c6e88215-0178-4c6c-b5f3-158ff77b1f38/NetFx20SP2_x86.exe' '$TEMP\NetFx20SP2_x86.exe'
Pop $R0
StrCmp $R0 "success" + SetDetailsPrint textonly
DetailPrint "正在安装 .NET Framework 2.0 SP2..."
SetDetailsPrint listonly
ExecWait '$TEMP\NetFx20SP2_x86.exe /quiet /norestart' $R1
Delete "$TEMP\NetFx20SP2_x86.exe" FunctionEnd Function DownloadNetFramework35
;下载 .NET Framework 3.5 SP1
NSISdl::download /TRANSLATE2 '正在下载 %s' '正在连接...' '(剩余 1 秒)' '(剩余 1 分钟)' '(剩余 1 小时)' '(剩余 %u 秒)' '(剩余 %u 分钟)' '(剩余 %u 小时)' '已完成:%skB(%d%%) 大小:%skB 速度:%u.%01ukB/s' /TIMEOUT= /NOIEPROXY 'http://download.microsoft.com/download/2/0/E/20E90413-712F-438C-988E-FDAA79A8AC3D/dotnetfx35.exe' '$TEMP\dotnetfx35.exe'
Pop $R0
StrCmp $R0 "success" + SetDetailsPrint textonly
DetailPrint "正在安装 .NET Framework 3.5 SP1..."
SetDetailsPrint listonly
ExecWait '$TEMP\dotnetfx35.exe /quiet /norestart' $R1
Delete "$TEMP\dotnetfx35.exe" FunctionEnd Function DownloadNetFramework4
;下载 .NET Framework 4.0
NSISdl::download /TRANSLATE2 '正在下载 %s' '正在连接...' '(剩余 1 秒)' '(剩余 1 分钟)' '(剩余 1 小时)' '(剩余 %u 秒)' '(剩余 %u 分钟)' '(剩余 %u 小时)' '已完成:%skB(%d%%) 大小:%skB 速度:%u.%01ukB/s' /TIMEOUT= /NOIEPROXY 'http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe' '$TEMP\dotNetFx40_Full_x86_x64.exe'
Pop $R0
StrCmp $R0 "success" + SetDetailsPrint textonly
DetailPrint "正在安装 .NET Framework 4.0 Full..."
SetDetailsPrint listonly
ExecWait '$TEMP\dotNetFx40_Full_x86_x64.exe /quiet /norestart' $R1
Delete "$TEMP\dotNetFx40_Full_x86_x64.exe" FunctionEnd Function DownloadNetFramework45
;下载 .NET Framework 4.5
NSISdl::download /TRANSLATE2 '正在下载 %s' '正在连接...' '(剩余 1 秒)' '(剩余 1 分钟)' '(剩余 1 小时)' '(剩余 %u 秒)' '(剩余 %u 分钟)' '(剩余 %u 小时)' '已完成:%skB(%d%%) 大小:%skB 速度:%u.%01ukB/s' /TIMEOUT= /NOIEPROXY 'http://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe' '$TEMP\NDP452-KB2901907-x86-x64-AllOS-ENU.exe'
Pop $R0
StrCmp $R0 "success" + SetDetailsPrint textonly
DetailPrint "正在安装 .NET Framework 4.5.2 ..."
SetDetailsPrint listonly
ExecWait '$TEMP\NDP452-KB2901907-x86-x64-AllOS-ENU.exe /quiet /norestart' $R1
Delete "$TEMP\NDP452-KB2901907-x86-x64-AllOS-ENU.exe" FunctionEnd
上一篇:CF 191C Fools and Roads lca 或者 树链剖分


下一篇:ABAP 读取EXCEL文件到内表