net framework updates via batch

Discussion in 'Windows 7' started by RanCorX2, Nov 24, 2013.

  1. RanCorX2

    RanCorX2 MDL Addicted

    Jul 19, 2009
    999
    554
    30
    does anyone know how to install a bunch of net framework updates in a batch? they always take ages to install one by one.

    i thought i saw a custom installer on the forums once but can't seem to find it.
     
  2. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #2 NICK@NUMBER11, Nov 24, 2013
    Last edited by a moderator: Apr 20, 2017
    copy and paste this code into notepad and save as instal.cmd, then place in the same folder as your updates and run.....

    Code:
    @echo off
    TITLE WUSA: Windows Update Installer
    ::Code by NICK@NUMBER11 and s1ave77
    CLS
    setlocal ENABLEDELAYEDEXPANSION
    pushd "%~dp0"
    echo:
    echo Getting Ready Windows Update
    echo:
    for /F %%a in ('dir *.msu ^| find /i "file(s)"') do set z=%%a
    if "%z%"=="" goto :Failure
    echo Updates found: %z%
    echo:
    echo Installing Windows Updates...please wait. This may take a while.
    echo:
    FOR /R "%~dp0" %%A IN (*.MSU) DO (
            SET /A COUNT+=1
            ECHO= Installing !COUNT! of %z% = %%~nA
            >NUL TIMEOUT /t 3
            WUSA "%%A" /quiet /norestart
    )
    echo Done installing %z% updates on %date% at %time%.
    echo:
    echo You should reboot now!
    CHOICE /C YN /N /M "Reboot now? [Y]es [N]o :"
    if %errorlevel%==1 goto :Reboot
    if %errorlevel%==2 goto :Exit
    :Failure
    CLS
    echo ==========================================================
    echo:
    echo    NO UPDATES FOUND
    echo:
    echo    NOTE: Updates must be in same directory as this script.
    echo:
    echo ==========================================================
    echo:
    pause
    goto :Exit
    :Reboot
    ENDLOCAL
    start shutdown.exe /r /t 0    
    :Exit
    ENDLOCAL
    exit


     
  3. RanCorX2

    RanCorX2 MDL Addicted

    Jul 19, 2009
    999
    554
    30
    thanks but it didn't work, that script is for windows updates. i've got a folder of .msp updates for framework 4.0.
     
  4. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #4 NICK@NUMBER11, Nov 24, 2013
    Last edited by a moderator: Apr 20, 2017
    Ok sorry you could use this command then...

    Code:
    msiexec /p filename.msp REINSTALL=ALL REINSTALLMODE=omus
     
  5. RanCorX2

    RanCorX2 MDL Addicted

    Jul 19, 2009
    999
    554
    30
    #5 RanCorX2, Nov 24, 2013
    Last edited by a moderator: Apr 20, 2017
    (OP)
    how do i use the command with lots of files?
     
  6. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    You just need to have a line for each file and change the file name as required
     
  7. RanCorX2

    RanCorX2 MDL Addicted

    Jul 19, 2009
    999
    554
    30
    oh right, cheers man.
     
  8. ricktendo64

    ricktendo64 MDL Expert

    Apr 20, 2008
    1,397
    2,024
    60
    #8 ricktendo64, Nov 24, 2013
    Last edited by a moderator: Apr 20, 2017
    What version framework are you using?

    You have a couple options, use original .net 4.5.1 because it requires no updates (so far,) use one of the updated installers in my sig (they have the updates integrated,) or use this batch file to patch the framework installer "on the fly" and have the updates install at the same time (its meant for .net 4.5 but will work for 4.0 or 4.5.1, just extract the MSP files and put them in a x86 or a x64 folder in the same dir as your installer)

    Code:
    @ECHO off & setlocal EnableDelayedExpansion
    SET "O_LOGFILE=%systemdrive%\install.log"
    
    :PROCESSOR
    REM :: Detect OS bit-ness on running system. Assumes 64-bit unless 64-bit components do not exist. 
    SET "ARCH=64" & SET "ARCHP=x64"
    IF /I NOT EXIST "%SystemRoot%\SysWOW64\cmd.exe" (
        IF NOT DEFINED PROCESSOR_ARCHITEW6432 (SET "ARCH=32" & SET "ARCHP=x86")
    ) 
    ECHO>>"%O_LOGFILE%" 2>>&1 System architecture is %ARCH% bit.
    :PROCESSOR_end
    
    :NET_Framework_45
    REM :: Change below path to where the NET45 installer/updates are stored.
    SET "D_NET45path=%CD%"
    IF /I NOT EXIST "%D_NET45path%\dotnetfx45_full_x86_x64.exe" GOTO NET_Framework_45_end
    ECHO>>"%O_LOGFILE%" ......................
    ECHO>>"%O_LOGFILE%" 2>>&1 Installing .NET 4.5 Framework
    SET "F_NET45msp="
    FOR /F %%m IN ('dir /b /s "%D_NET45path%\%ARCHP%\NDP45-KB*.msp"') DO (
      IF NOT DEFINED F_NET45msp (SET "F_NET45msp=%%m") ELSE (SET "F_NET45msp=!F_NET45msp!;%%m")
      ECHO %%m
    ) 1>>"%O_LOGFILE%" 2>>&1
    
    ECHO>>"%O_LOGFILE%" 2>>&1 Executing: %D_NET45path%\dotnetfx45_full_x86_x64.exe /passive /norestart /MSIOPTIONS "PATCH=%F_NET45msp%"
    %D_NET45path%\dotnetfx45_full_x86_x64.exe /passive /norestart /MSIOPTIONS "PATCH=%F_NET45msp%" >>"%O_LOGFILE%" 2>>&1
    
    ECHO>>"%O_LOGFILE%" 2>>&1 Completed .NET 4.5 Framework installation
    :NET_Framework_45_end
    EXIT
     
  9. Hoppyah

    Hoppyah MDL Senior Member

    Aug 12, 2009
    294
    14
    10
    #9 Hoppyah, Nov 26, 2013
    Last edited by a moderator: Apr 20, 2017
    ricktendo64 are those silent installers in your sig or should i use the dotnet sfxmaker??
     
  10. ricktendo64

    ricktendo64 MDL Expert

    Apr 20, 2008
    1,397
    2,024
    60
    Not silent, if you look closely I provide a SFX maker so you can repack it (for 100% silent, replace those files in the SFX maker with the ones in "No GUI" archive I also provide)

    Simply use the SFX splitter on the <INSTALLER>.EXE to split off your 7z, then drag&drop the 7z onto the BAT to rebuild the installer with the silent commands
     
  11. Hoppyah

    Hoppyah MDL Senior Member

    Aug 12, 2009
    294
    14
    10