Archive: .Net installation of specific version


.Net installation of specific version
Could someone look over this function and tell me what is wrong? Basically I want to check and see if the .Net Framework 2.0 is installed, if it is not then install it. It is working up to the point that if 2.0 is already installed it trys to install it anyways. I modified the example they have on the website just a hair.

Thank you

Function .onInit
Call GetDotNETVersion
Pop $0
${If} $0 == "not found"
MessageBox MB_OKCANCEL "We have detected that you do not have Microsoft .NET Framework 2.0 Installed. Press OK to install .NET Framework." IDOK installNET IDCANCEL 0
Abort
${EndIf}

StrCpy $0 $0 "" 1 # skip "v"

${VersionCompare} $0 "2.0" $1
${If} $1 == 2
MessageBox MB_OKCANCEL "We have detected that you do not have Microsoft .NET Framework 2.0 Installed. Press OK to install .NET Framework." IDOK installNET IDCANCEL 0
Abort
${EndIf}
installNET:
SetOutPath "$INSTDIR\bin"
SetOverwrite ifnewer
File "c:\Program Files\Progam\bin\dotnetfx.exe"
ExecWait '"$INSTDIR\bin\dotnetfx.exe"'
FunctionEnd

Function GetDotNETVersion
Push $0
Push $1

System::Call "mscoree::GetCORVersion(w .r0, i ${NSIS_MAX_STRLEN}, *i) i .r1"
StrCmp $1 "error" 0 +2
StrCpy $0 "not found"

Pop $1
Exch $0
FunctionEnd


You overwrite the result of GetDotNETVersion with nothing, if .NET is installed. You should use LogicLib (${If}, ${AndIf}, etc.) for the entire logic of that function.