.NET 4.7 silent install for Windows 7, detect prerequisites

CatOnRug solve, automate, speed up .NET 4.7 silent install for Windows 7, detect prerequisites
This will install .NET 4.7 for 32-bit and 64-bit Windows 7.

Here are features implemented:
  • install .NET 4.7 for Windows 7 x64 and Windows 7 x86
  • skip installation if computer restart is needed
  • do not let execute windows installer instance if another is in progress
  • install prerequisites if needed. solves this screen:
    .NET Framework Blocking Issue for Windows 7. Prerequisites are needed. KB4019990
  • detect reboot for prerequisite
  • install .NET 4.7
  • show reboot if needed

Files needed:
Windows6.1-KB4019990-x64.msu
c1621140774b2d6117e4b7a3c48858e4
35cc310e81ef23439ba0ec1f11d7b71dd34adfe5

Windows6.1-KB4019990-x86.msu
9050007ae034097618d8ef5ebb49685a
1365fb557d5e5917cbf59b507eac066ad89ea3f7

NDP47-KB3186497-x86-x64-AllOS-ENU.exe
b59040e489bff55433508438627d11e6
76054141a492ba307595250bda05ad4e0694cdc3

Here is the installation script:
@echo off
cls

setlocal EnableDelayedExpansion

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" > nul 2>&1
if not !errorlevel!==0 (

tasklist | findstr "msiexec" > nul 2>&1
if not !errorlevel!==0 (

echo Looking for any .NET 4.7 version
reg query "HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" > nul 2>&1
rem looking for exact 4.7 version
if !errorlevel!==0 reg query "HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.7" > nul 2>&1
if not !errorlevel!==0 set notInstalled=1

if !notInstalled!==1 (
echo ..not found
echo.

echo looking for prerequisites..

rem look if Windows 7 or Server 2008 R2 OS
ver | find "Version 6.1" > nul 2>&1
if !errorlevel!==0 (
echo windows 7 detected

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" /s | find "KB4019990"
if not !errorlevel!==0 (
echo installing KB4019990..

if not "%ProgramFiles(x86)%"=="" %systemroot%\system32\wusa.exe "%~dp0Windows6.1-KB4019990-x64.msu" /quiet /norestart
if "%ProgramFiles(x86)%"=="" %systemroot%\system32\wusa.exe "%~dp0Windows6.1-KB4019990-x86.msu" /quiet /norestart
echo installation ended with code !errorlevel!
if !errorlevel!==0 set mark4install=1
if !errorlevel!==3010 echo computer restart is needed!
echo.

) else echo prerequisites OK

) else echo this is not Windows 7 or Server 2008 R2 operating system

if !mark4install!==1 (
echo installing .NET Framework 4.7
start /wait "" "%~dp0NDP47-KB3186497-x86-x64-AllOS-ENU.exe" /passive /norestart
echo installation ended with code !errorlevel!
if !errorlevel!==3010 echo computer restart is needed to complete installation
echo.
) else echo no need to execute .NET 4.7 installation

) else echo .NET 4.7 already installed
echo.
) else echo another Windows Installer msiexec process doing something. Cannot continue
) else echo computer restart is needed before continue

endlocal

pause

No comments:

Post a Comment