NSIS Installer with .NET 4.5

走远了吗. 提交于 2019-12-12 10:46:13

问题


I'm after some code snippets for NSIS to detect and conditionally run the .NET 4.5 installer

This answer - NSIS Installer with .NET 4.0 - is too naive as checking only the presense of the registry key (not the value) will not discriminate between 4.0 and 4.5


回答1:


You shouldn't check for an exact version number. This will change in the future (as was the case for 4.0 > 4.5). Instead use the codes from the deployment guide.

In addition to that you should try to handle the reboot from .Net 4.5.

Function CheckAndInstallDotNet
    ; 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 >= 378389

        DetailPrint "Microsoft .NET Framework 4.5 is installed ($0)"
    ${Else}
    NotDetected:
        DetailPrint "Installing Microsoft .NET Framework 4.5"
        SetDetailsPrint listonly
        ExecWait '"$INSTDIR\Tools\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}

FunctionEnd


来源:https://stackoverflow.com/questions/12849352/nsis-installer-with-net-4-5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!