Function GetNetFrameworkVersion ;获取.Net Framework版本支持 Push $1 Push $0 ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv4Full" "Install" ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv4Full" "Version" StrCmp $0 1 KnowNetFrameworkVersion +1 ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv3.5" "Install" ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv3.5" "Version" StrCmp $0 1 KnowNetFrameworkVersion +1 ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv3.0Setup" "InstallSuccess" ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv3.0Setup" "Version" StrCmp $0 1 KnowNetFrameworkVersion +1 ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv2.0.50727" "Install" ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv2.0.50727" "Version" StrCmp $1 "" +1 +2 StrCpy $1 "2.0.50727.832" StrCmp $0 1 KnowNetFrameworkVersion +1 ReadRegDWORD $0 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv1.1.4322" "Install" ReadRegDWORD $1 HKLM "SOFTWAREMicrosoftNET Framework SetupNDPv1.1.4322" "Version" StrCmp $1 "" +1 +2 StrCpy $1 "1.1.4322.573" StrCmp $0 1 KnowNetFrameworkVersion +1 ReadRegDWORD $0 HKLM "SOFTWAREMicrosoft.NETFrameworkpolicyv1.0" "Install" ReadRegDWORD $1 HKLM "SOFTWAREMicrosoft.NETFrameworkpolicyv1.0" "Version" StrCmp $1 "" +1 +2 StrCpy $1 "1.0.3705.0" StrCmp $0 1 KnowNetFrameworkVersion +1 StrCpy $1 "not .NetFramework" KnowNetFrameworkVersion: Pop $0 Exch $1 FunctionEnd
需要加在:.onInit中
Call GetNetFrameworkVersion Pop $1 ${If} $1 < '2.0.50727' MessageBox MB_OK "检测到您的系统未安装.NET Framework2.0,单击【确定】进行安装。" SetDetailsPrint textonly DetailPrint "检测到您的系统未安装.NET Framework2.0,单击【确定】进行安装。" SetDetailsPrint listonly SetOutPath "$TEMP" SetOverwrite on File "NetFx20SP2_x86.exe" ExecWait '$TEMPNetFx20SP2_x86.exe' $R1 ; /quiet /norestart Delete "$TEMPNetFx20SP2_x86.exe" ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY