Windows XP上的NSIS .NET4.5安装程序

时间:2013-09-05 13:46:04

标签: function installer installation .net-4.5 nsis

全部,我有以下NSIS函数检查.NET4.5 +,如果没有安装,则启动Web安装程序(如果有Internet连接)并且安装.NET4.5后安装继续。这适用于Windows 7和8,但它无法正常用于Windows XP。功能是

Function CheckAndInstallDotNet
    ; Installer dotNetFx45_Full_setup.exe avalible from http://msdn.microsoft.com/en-us/library/5a4x27ek.aspx
    ; Magic numbers from http://msdn.microsoft.com/en-us/library/ee942965.aspx
    ClearErrors
    ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Release"
    IfErrors NotDetected
    ${If} $0 >= 378181 ;378389
        DetailPrint "Microsoft .NET Framework 4.5 is installed ($0)"
    ${Else}
    NotDetected:
        MessageBox MB_YESNO|MB_ICONQUESTION ".NET Framework 4.5+ is required for UserCost2013, \
            do you want to launch the web installer? This requires a valid internet connection." IDYES InstallDotNet IDNO Cancel 
        Cancel:
            MessageBox MB_ICONEXCLAMATION "To install UserCost2013, Microsoft's .NET Framework v${DOT_MAJOR}.${DOT_MINOR} \
                (or higher) must be installed. Cannot proceed with the installation!"
            ${OpenURL} "${WWW_MS_DOTNET4_5}"
            RMDir /r "$INSTDIR" 
            SetOutPath "$PROGRAMFILES"
            RMDir "$INSTDIR" 
            Abort

        ; Install .NET4.5.
        InstallDotNet:
            DetailPrint "Installing Microsoft .NET Framework 4.5"
            SetDetailsPrint listonly
            ExecWait '"$INSTDIR\dotNETFramework\dotNetFx45_Full_setup.exe" /passive /norestart' $0
            ${If} $0 == 3010 
            ${OrIf} $0 == 1641
                DetailPrint "Microsoft .NET Framework 4.5 installer requested reboot."
                SetRebootFlag true 
            ${EndIf}
            SetDetailsPrint lastused
            DetailPrint "Microsoft .NET Framework 4.5 installer returned $0"
    ${EndIf}

    ; Now remove the dotNETFramework directory and contents.
    RMDir /r "$INSTDIR\dotNETFramework" 
    ;Delete "$INSTDIR\dotNETFramework\dotNetFx45_Full_setup.exe"
    ;RMDir "$INSTDIR\dotNETFramework" 
FunctionEnd

问题在于ExecWait,它执行web安装程序'dotNetFx45_Full_setup.exe'并解压缩所需的临时文件。然后,当在Win7 / 8的情况下,它启动安装程序,在XP中它没有。相反,它继续安装我的应用程序而不安装.NET。不用说这会给XP用户带来问题。

如何在XP中正常使用此功能?

感谢您的时间。

1 个答案:

答案 0 :(得分:1)

Windows XP不支持.NET4.5,这就是安装程序退出而不做任何事情的原因。

http://channel9.msdn.com/Forums/Coffeehouse/Why-is-XP-Support-for-NET-45-not-happening

.NET 4.5 RC Framework CLR - Windows XP compatibility

......以及许多其他StackOverflow问题。