Search code examples
nsis

NSIS Scripting Condidtional Section / SectionGroup


Apparently, I can't find any help on this. I have a scenario where I want to check if the user has a certain version of the .NET Framework installed on his or her machine. If not, I want to display a mandetory section inside a section-group that let's the user know that a particular version of the .NET Framework is a prerequisite and it will be installed prior to installing the application. How can I go about doing something like this?

Thanks!


Solution

  • Outfile "test.exe"
    Requestexecutionlevel user
    
    !include Sections.nsh
    !include LogicLib.nsh
    
    Page Components MyCompPreCallback
    Page Instfiles
    
    
    SectionGroup /e Foo
    
    Section ".NET Framework vX.Y" SEC_DOTNET
    SectionIn RO
    ;File ...
    SectionEnd
    
    SectionGroupEnd
    
    
    Function MyCompPreCallback
    
    StrCpy $0 1 ;TODO: Check if .net is installed and put result in $0
    
    ${If} $0 <> 0
        !insertmacro UnselectSection ${SEC_DOTNET}
    ${EndIf}
    
    FunctionEnd
    

    You can find information about finding the installed version of .NET on this blog and by searching the nsis wiki