Jaimesh
Jaimesh

Reputation: 851

Enable .Net Framework 3.5 SP1 from 'Programs and Features' and install it using NSIS

I am creating installer using nsis for my windows form application. I need .Net Framework 3.5 SP1 as pre-requisites for my application. So using NSIS i check if it is available in client machine or not. If not then it will install it silently. But it gives me an error. I know .Net Framework 3.5 SP1 is required to enable from 'Program and Features' in control panel.

So how can i enable feature '.NET FRAMEWORK 3.5' from control panel using NSIS script.

My nsis section to check and install .Net Framework 3.5 SP1 is :

 section
    SetOutPath "$temp\Pre_requisites"
    ; check and install .Net Framework 3.5SP1
    ReadRegStr $R1 HKLM "Software\Microsoft\NET Framework Setup\NDP\v3.5" "SP"
    ${If} $R1 != "1"
                   DetailPrint "Microsoft .NET Framework 3.5 SP1 needed. Installing..."              
                   File "$temp\Pre_requisites\dotnetfx35.exe"      
                   ExecWait '"$temp\Pre_requisites\dotnetfx35.exe" /q /norestart'
    ${Else}
    DetailPrint "Microsoft .NET Framework 3.5 SP1 Found."
    ${EndIf}
 sectionend

Error message is(I have tried this in windows 7 SP1 64bit):

enter image description here

Thanks..!

Upvotes: 4

Views: 4354

Answers (2)

Dev
Dev

Reputation: 72

Execute below code. It execute dism.exe with enable feature parameter by command prompt for .Net Framework 3.5 online installation.

     section
        ; check and install .Net Framework 3.5SP1
        ReadRegStr $R1 HKLM "Software\Microsoft\NET Framework Setup\NDP\v3.5" "SP"
        ${If} $R1 != "1"
                       DetailPrint "Microsoft .NET Framework 3.5 SP1 needed. Installing..."              
                       nsExec::Exec 'cmd /c %windir%\system32\dism.exe /Online /Enable-Feature /FeatureName:NetFx3 /All'   
        ${Else}
        DetailPrint "Microsoft .NET Framework 3.5 SP1 Found."
        ${EndIf}
     sectionend

Upvotes: 2

Jean Fiedler
Jean Fiedler

Reputation: 171

Nearly 99,9% of all Windows 7 Installations have installed .Net 3.5 by default. Because it is a feature build in into the source. Please check the registry to find out wich exact version of .net is installed. If you really need to install .net 3.5 under Windows 7 check out https://technet.microsoft.com/de-de/library/dn482069.aspx. Because you need to use DSIM to install .net 3.5 under Windows 7. The Installer is just for Windows XP and lower.

Upvotes: 2

Related Questions