2013-09-05 62 views
0

所有,我有以下NSIS函數檢查.NET4.5 +,如果沒有安裝,Web安裝程序啓動(如果有互聯網連接)和安裝一旦.NET4.5安裝完成就會繼續。這適用於Windows 7和8,但在Windows XP中無法正常工作。該功能是在Windows XP上的NSIS .NET4.5安裝程序

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中正常使用此功能?

謝謝你的時間。

回答