kporter20
5th October 2008 10:52 UTC
Detect if .NET 3.5 is installed
Hi, first post here.
I have an application I have developed which requires .NET 3.5 to be installed.
How do I detect if this runtime is installed?
I have managed this for applications using .NET 2.0 but how I detect if .NET 3.5 is installed.
Thanks
Anders
5th October 2008 13:00 UTC
This might work, I don't have .net 3.X so I can't test
GetDllVersion "$sysdir\mscoree.dll" $R0 $R1
IntOp $R0 $R0 / 0x00010000
${If} $R0 >= 2
        
        ;http://blogs.msdn.com/junfeng/archiv...07/436755.aspx
        !define RUNTIME_INFO_UPGRADE_VERSION 0x01
        !define RUNTIME_INFO_DONT_RETURN_DIRECTORY 0x10
        !define RUNTIME_INFO_DONT_SHOW_ERROR_DIALOG 0x40
        System::Call "mscoree::GetRequestedRuntimeInfo(i0,i0,i0,i0,i ${RUNTIME_INFO_UPGRADE_VERSION}|${RUNTIME_INFO_DONT_RETURN_DIRECTORY}|${RUNTIME_INFO_DONT_SHOW_ERROR_DIALOG},\
                i0,i0,*i,w .r0, i ${NSIS_MAX_STRLEN}, *i)i.r1"
                
        ${If} $1 == 0
                MessageBox mb_ok Version=$0
        ${Else}
                MessageBox mb_ok error=$1
        ${EndIf}
${EndIf}
    
      kporter20
      6th October 2008 09:42 UTC
      First test of this seemed to return v2.0... even if 3.0/3.5 is installed.
     
    
      Anders
      6th October 2008 09:44 UTC
      so the message box says Version=2.0 when you run it?
     
    
      kporter20
      6th October 2008 15:04 UTC
      Yes. It corresponds to the version of the CLR that the .NET Framework is using I think. As .NET 3.5 still uses the 2.0 CLR this is what is getting reported.
     
    
      Animaether
      6th October 2008 15:16 UTC
      blatant copy/paste from a previous post;
      
      check the following code sample from Aaron Stebner (*tips hat*) for detecting the various .NET framework versions and service packs:
      http://astebner.sts.winisp.net/Tools/detectFX.cpp.txt
     
    
      kporter20
      7th October 2008 20:03 UTC
      I have tried to use some of this inside an NSIS installer file to detect if just .NET 3.5 is installed but none of it seems to compile properly.
     
    
      Animaether
      7th October 2008 20:09 UTC
      hi kporter.. that's because that code is in C++, rather than in NSIS language. Basically, though, it's reading out of registry values (ReadRegStr etc.) to determine if the product was installed or not
     
    
      kporter20
      7th October 2008 20:47 UTC
      OK. I'll wade through the parts I think I need and convert it to the NSIS language.
      
      Thanks
     
    
      Animaether
      7th October 2008 21:30 UTC
      I'm making a header file for this, but ran into a potential problem with VersionCompare.. *groan*
      
      Also I'm currently installing Framework 3.5.. make sure that check actually works.. and of course it asks me to close pretty much every application I have open. yeesh.