[Batch] Extract and prepare Office MSP files

Discussion in 'Microsoft Office' started by hearywarlot, Aug 10, 2015.

  1. hearywarlot

    hearywarlot MDL Member

    Jul 31, 2015
    105
    98
    10
    #1 hearywarlot, Aug 10, 2015
    Last edited: Jul 26, 2017
    Recursively extracts MSP files from Office KB packages to a folder with meaningful names.

    The MSP files will be renamed with prefix 'Z_' followed by the package name, KB ID, Arch and MSP file name.
    This will nicely sort MSP alphabetically, stop conflicts and allow service packs to be alphabetically installed first.

    To make your life easier, use this script with WHDownloader.
    forums.mydigitallife.net/threads/66243/

    Usage:
    The script has 5 variables.
    • dirOfExe="Folder to execute EXE"
    • dirOfMsp="Folder to extract MSP"
    • OldMSPdir="Folder to move old MSP versions"
    • langOfMSP="KB Language"
    • ProofLang="Proof Language's"
    You can use the variables like this:
    Code:
    SET "dirOfExe=D:\WHDownloader\Updates\Office2016-x64"
    SET "dirOfMsp=E:\MSPs"
    SET "OldMSPdir=E:\oldMSPs"
    SET "langOfMSP=nl-nl"
    SET "ProofLang=en-us,fr-fr,de-de"
    
    The script can also be used externally from CMD with Unix like options.
    It will accept 6 options, with each option having a short or long version.
    • -e or --dirOfExe [Folder to execute EXE]
    • -m or --dirOfMsp [Folder to extract MSP]
    • -o or --OldMSPdir [Folder to move old MSP versions]
    • -l or --langOfMSP [KB Language]
    • -p or --ProofLang [Proof Language's]
    • -h or --help (Will display help text)
    Options override presets in the script.
    Using the script with options will allow batch jobs, quickly creating multiple updated Office bases on a whim.
    Example:
    Code:
    Extract_Msp_Office.cmd -e "D:\WHDownloader\Updates\Office2010-x86" -m "E:\2010_x86_EN_MSPs" OldMSPdir="E:\OLD-2010_x86_MSPs" -l "en-us" -ProofLang="fr-fr,es-es"
    Extract_Msp_Office.cmd --dirOfEXE="D:\WHDownloader\Updates\Office2013-x64" -m "E:\2013_x64_NL_MSPs" -o "E:\OLD-2013_x64_MSPs" --langOfMSP="nl-nl" -p "en-us,fr,fr,de-de"
    Extract_Msp_Office.cmd --dirOfEXE="D:\WHDownloader\Updates\Office2016-x64" --dirOfMSP="E:\2016_x64_MSPs" OldMSPdir="E:\OLD-2016_x64_MSPs"
    For a list of possible languages to use:
    LocaleLCID
    Albaniansq-al
    Amharic (Ethiopia)am-et
    Arabicar-SA
    Arabicar-SA
    Arabicar-SA
    Arabicar-SA
    Armenianhy-am
    Assamese (India)as-in
    Azeri (Latin) (Azerbaijan)az-latn-az
    Basque (Spain)eu-es
    Bengali (Bangladesh)bn-bd
    Bengali (India)bn-in
    Bosnia and Herzegovinabs-latn-ba
    Bulgarianbg-bg
    Catalan (Spain)ca-es
    Croatianhr-hr
    Cyrillic (Serbia)sr-cyrl-cs
    Czechcs-CZ
    Danishda-DK
    Dutchnl-NL
    Englishen-US
    Estonian (Estonia)et-ee
    Farsi (Iran)fa-ir
    Filipino (Philippines)fil-ph
    Finnishfi-FI
    Frenchfr-FR
    FYRO Macedonian (Former Yugoslav Republic of Macedonia)mk-mk
    Galiciangl-es
    Georgianka-ge
    Germande-DE
    Greekel-GR
    Gujarati (India)gu-in
    Hausa (Latin, Nigeria)ha-latn-ng
    Hebrewhe-IL
    Hindi (India)hi-in
    Hungarianhu-HU
    Icelandicis-is
    Igbo (Nigeria)ig-ng
    Indonesianid-id
    Inuktitut (Latin, Canada)iu-latn-ca
    Irish (Ireland)ga-ie
    Italianit-IT
    Japaneseja-JP
    Kannada (India)kn-in
    Kazakh (Kazakhstan)kk-kz
    Khmer (Cambodia)km-kh
    Konkani (India)kok-in
    Koreanko-KR
    Kyrgyz (Kyrgyzstan)ky-kg
    Latin (Serbia)sr-latn-cs
    Latvianlv-lv
    Lithuanianlt-lt
    Luxembourgish (Luxembourg)lb-lu
    Malay (Brunei Darussalam)ms-bn
    Malay (Malaysia)ms-my
    Malayalam (India)ml-in
    Maltesemt-mt
    Maori (New Zealand)mi-nz
    Marathi (India)mr-in
    Nepali (Nepal)ne-np
    Norwegian (Nynorsk) (Norway)nn-no
    Norwegiannb-NO
    Oriya (India)or-in
    Polishpl-PL
    Portuguesept-PT
    PortugueseBRpt-BR
    Punjabi (India)pa-in
    Quechua (Peru)quz-pe
    Romanianro-ro
    Russianru-RU
    Sesotho sa Leboa (South Africa)nso-za
    SimpChinesezh-CN
    Slovaksk-sk
    Sloveniansl-si
    Spanishes-ES
    Swahili (Kenya)sw-ke
    Swedishsv-SE
    Tamil (India)ta-in
    Tatar (Russia)tt-ru
    Telugu (India)te-in
    Thaith-th
    TradChinesezh-TW
    Tswana (South Africa)tn-za
    Turkishtr-TR
    Ukrainianuk-ua
    Urdu (Islamic Republic of Pakistan)ur-pk
    Uzbek (Latin) (Uzbekistan)uz-latn-uz
    Vietnamesevi-vn
    Welsh (United Kingdom)cy-gb
    Xhosa (South Africa)xh-za
    Yoruba (Nigeria)yo-ng
    Zulu (South Africa)zu-za

    Proofing package has additional companion languages.
    To find out which you need, check out the link below which fit with your office version.
    • Office 2010:
      • technet.microsoft.com/en-us/library/ee942198(v=office.14).aspx
    • Office 2013/365 ProPlus:
      • technet.microsoft.com/en-us/library/ee942198(v=office.15).aspx
    • Office 2016:
      • Not needed, all packages are language neutral or automatically chosen.

    Code:
    Filename: Extract_MSP_Office.cmd
    Code:
    <!-- : Begin batch script
    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION
    mode con cols=180 lines=777
    
    FSUTIL dirty query "!SYSTEMDRIVE!" >nul || (
       ECHO(*************************************
       ECHO(Invoking UAC for Privilege Escalation
       ECHO(*************************************
       CSCRIPT //nologo "%~f0?.wsf" //job:ELAV /File:"%~f0" %*
       EXIT /B
    )
    
    
    SET "dirOfEXE=D:\WHDownloader\Updates\Office2010-x64"
    SET "dirOfMSP=%~dp0MSPs"
    SET "OldMSPdir=!dirOfMSP!\OLD"
    SET "langOfMSP=en-us"
    SET "ProofLang=fr-fr,es-es"
    
    
    :EvalOpt
    FOR %%A in ( "h|Help" "e|dirOfEXE" "m|dirOfMSP" "o|OldMSPdir" "l|langOfMSP" "p|ProofLang" ) do (
       FOR /f "delims=| tokens=1-2" %%B in ( "%%~A" ) do (
           SET "optShort=%%B"
           SET "optLong=%%C"
           SET "TEST=;-!optShort!;--!optLong!;"
           IF not "!TEST:;%~1;=!"=="!TEST!" (
               IF "!optLong!"=="Help" (
                       ECHO(Recursively extracts MSP files from Office KB packages to a folder with meaningful names
                       ECHO(
                       ECHO(Options:
                       ECHO( -e   --dirOfEXE   [Folder to execute EXE]
                       ECHO( -m   --dirOfMSP   [Folder to extract MSP]
                       ECHO( -o   --OldMSPdir   [Folder to move old MSP versions]
                       ECHO( -l   --langOfMSP   [KB Language]
                       ECHO( -p   --ProofLang   [Proof Language's]
                       ECHO( -h   --Help       ^(Will display help text^)
                       ECHO(
                       ECHO(Example:
                       ECHO( "file.cmd" -e "D:\WHDownloader\Updates\Office2010-x64" --dirOfMSP "E:\MSPs" -o "E:\oldMSPs" --langOfMSP "en-us" -p "fr-fr,es-es"
                       ECHO(
                       ECHO(Proofing package has additional companion languages.
                       ECHO(To find out which you need, check out the link below which fit with your office version.
                       ECHO( Office 2010:                 "technet.microsoft.com/en-us/library/ee942198(v=office.14).aspx"
                       ECHO( Office 2013/365 ProPlus:  "technet.microsoft.com/en-us/library/ee942198(v=office.15).aspx"
                       ECHO( Office 2016:                 Not needed, all packages are language neutral or automatically chosen.
                       PAUSE
                       EXIT /B
               ) else (
                       SET "!optLong!=%~2"
                       SHIFT /1
               )
               GOTO :breakEvalOpt
           )
       )
    )
    :breakEvalOpt
    IF not "%~1"=="" (
       SHIFT /1
       GOTO :EvalOpt
    )
    FOR %%A in ( "dirOfEXE" "dirOfMSP" "OldMSPdir" ) do (
           SET "optVital=%%~A"
           IF not defined !optVital! (
               ECHO(Please enter data for '!optVital!' of your Office Updates"
               SET /p "!optVital!=!optVital!:"
               ECHO(
           )
           If "!%%~A!"=="" (
               ECHO(Error: Can't continue because of empty var: '!optVital!'^^!
               PAUSE
               EXIT /b
           )
       )
    )
    
    
    DIR /a-d /s "!dirOfEXE!\*-*-*-*-*.exe" >NUL 2>&1
    IF not !ERRORLEVEL! equ 0 (
       ECHO(ERROR: Folder or valid named Office update files could not be found at "!dirOfEXE!\"^^!
    ) else (
       CD /d "!dirOfEXE!\"
       IF not exist "!dirOfMSP!\" ( MKDIR "!dirOfMSP!" )
       FOR /r %%A in ("*-*-*-*-*.exe") do (
           PUSHD "%%~dpA"
           SET "fileOfEXE=%%~nA"
           ECHO(Extracting "!fileOfEXE!.exe"
           "!fileOfEXE!.exe" /quiet /extract:"!dirOfMSP!\!fileOfEXE!"
           IF not exist "!dirOfMSP!\!fileOfEXE!\" (
               SET "ercFailEXE=!ERRORLEVEL!"
               SET /a "cntFailEXE+=1"
               SET "excFailEXE!cntFailEXE!=%%~fA"
               SET "ercFailEXE!cntFailEXE!=!ercFailEXE!"
               ECHO(ERROR: No folder was made after executing "!fileOfEXE!.exe"^^!
           ) else (
               PUSHD "!dirOfMSP!\!fileOfEXE!\"
               ECHO(=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
               FOR /r %%B in ("*.msp") do (
                   SET "fileOfMSP=%%~nB"
                   FOR /f "delims=-" %%C in ( "!fileOfMSP!" ) do (
                       SET "nameOfMSP=%%C"
                       SET "TRUE="
                       IF "!langOfMSP!"=="" (
                           SET "TRUE=1"
                       ) else (
                           IF "!fileOfMSP!"=="!nameOfMSP!-x-none" (
                               SET "TRUE=1"
                           ) ELSE (
                               FOR %%D in ( !ProofLang! ) do (
                                   IF "!fileOfMSP!"=="proof-%%D" ( SET "TRUE=1" )
                               )
                               IF "!fileOfMSP!"=="!nameOfMSP!-!langOfMSP!" ( SET "TRUE=1" )
                           )
                       )
                       IF defined TRUE (
                           FOR /f "tokens=1-2,4 delims=-" %%D in ( "!fileOfEXE!" ) do (
                               SET "nameOfEXE=%%D"
                               SET "kbOfEXE=%%E"
                               SET "archOfEXE=%%F"
                           )
                           SET "NewMSPpath=!dirOfMSP!\Z_!nameOfEXE!_!kbOfEXE!_!archOfEXE!_!fileOfMSP!.msp"
                           ECHO(Moving "!fileOfMSP!.msp" to "!NewMSPpath!"
                           IF not exist "!NewMSPpath!" (
                               MOVE "!fileOfMSP!.msp" "!NewMSPpath!"
                           ) else (
                               ECHO( ^<= File already exists, skipping =^>
                           )
                       )
                   )
               )
               IF defined NewMSPpath (
                   FOR /F "tokens=1-5 delims=_" %%D in ('DIR /B /A:-D "!dirOfMSP!\Z_!nameOfEXE!_kb*_!archOfEXE!_*.msp"') do (
                       IF not "%%F" == "!kbOfEXE!" (
                           IF not exist "!OldMSPdir!\" ( MKDIR "!OldMSPdir!" )
                           SET "OldMSPfile=%%D_%%E_%%F_%%G_%%H"
                           ECHO( ^<= Moving older version " !OldMSPfile!" to "!OldMSPdir!" =^>
                           MOVE "!dirOfMSP!\!OldMSPfile!" "!OldMSPdir!\"
                       )
                   )
                   Set "NewMSPpath="
               ) else (
                   ECHO( ^<= Oh my, It appears none of the MSP files were applicable to your given languages =^>
               )
               ECHO(=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
               POPD
               ECHO(Removing folder "!dirOfMSP!\!fileOfEXE!\"
               RD /s /q "!dirOfMSP!\!fileOfEXE!\"
           )
           POPD
           ECHO(
           ECHO(
       )
       ECHO(
       IF defined ercFailEXE (
           ECHO(A number of !cntFailEXE! executables have failed to extract folders.
           ECHO(The following have failed:
           FOR /L %%A in (1,1,!cntFailEXE!) Do (
               ECHO(
               ECHO(File: "!excFailEXE%%A!"
               ECHO(Errorcode: "!ercFailEXE%%A!"
           )
       ) else (
           ECHO(Dinner is ready^^!
       )
    )
    
    ECHO(
    ECHO(
    ECHO(Written and maintained by Hearlywarlot
    ECHO(For updates on the script or other nice things visit our awesome Forum at:
    ECHO(forums.mydigitallife.net/threads/64028/
    ECHO(
    
    ENDLOCAL
    PAUSE
    EXIT /b
    ----- Begin wsf script --->
    <package>
       <job id="ELAV">
           <script language="VBScript">
               Set strArg=WScript.Arguments.Named
    
               If Not strArg.Exists("File") Then
                       Wscript.Echo "Switch /File:<File> is missing."
                       WScript.Quit 1
               End If
    
               Set strRdlproc = CreateObject("WScript.Shell").Exec("rundll32 kernel32,Sleep")
               With GetObject("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" & strRdlproc.ProcessId & "'")
                       With GetObject("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" & .ParentProcessId & "'")
                           If InStr (.CommandLine, WScript.ScriptName) <> 0 Then
                               strLine = Mid(.CommandLine, InStr(.CommandLine , "/File:") + Len(strArg("File")) + 8)
                           End If
                       End With
                       .Terminate
               End With
    
               CreateObject("Shell.Application").ShellExecute "cmd", "/c " & chr(34) & chr(34) & strArg("File") & chr(34) & " " & strLine & chr(34), "", "runas", 1
           </script>
       </job>
    </package>
    Code:
    <!-- : Begin batch script
    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION
    
    FSUTIL dirty query "!SYSTEMDRIVE!" >nul || (
       ECHO(*************************************
       ECHO(Invoking UAC for Privilege Escalation
       ECHO(*************************************
       CSCRIPT //nologo "%~f0?.wsf" //job:ELAV /File:"%~f0" %*
       EXIT /B
    )
    
    
    SET "dirOfEXE=D:\WHDownloader\Updates\Office2010-x64"
    SET "dirOfMSP=%~dp0MSPs"
    SET "langOfMSP=en-us"
    SET "ProofLang=fr-fr,es-es"
    
    
    :EvalOpt
    FOR %%A in ( "h|Help" "e|dirOfEXE" "m|dirOfMSP" "l|langOfMSP" "p|ProofLang" ) do (
       FOR /f "delims=| tokens=1-3" %%B in ( "%%~A" ) do (
           SET "optShort=%%B"
           SET "optLong=%%C"
           SET "TEST=;-!optShort!;--!optLong!;"
           IF not "!TEST:;%~1;=!"=="!TEST!" (
               IF "!optLong!"=="Help" (
                   ECHO(Recursively extracts MSP files from Office KB packages to a folder with meaningful names
                   ECHO(
                   ECHO(Options:
                   ECHO( -e   --dirOfEXE   [Folder to execute EXE]
                   ECHO( -m   --dirOfMSP   [Folder to extract MSP]
                   ECHO( -l   --langOfMSP  [KB Language]
                   ECHO( -p   --ProofLang  [Proof Language's]
                   ECHO( -h   --Help       ^(Will display help text^)
                   ECHO(
                   ECHO(Example:
                   ECHO( "file.cmd" -e "D:\WHDownloader\Updates\Office2010-x64" --dirOfMSP "E:\MSPs" --langOfMSP "en-us" -p "fr-fr,es-es"
                   ECHO(
                   ECHO(Proofing package has additional companion languages.
                   ECHO(To find out which you need, check out the link below which fit with your office version.
                   ECHO( Office 2010:              "technet.microsoft.com/en-us/library/ee942198(v=office.14).aspx"
                   ECHO( Office 2013/365 ProPlus:  "technet.microsoft.com/en-us/library/ee942198(v=office.15).aspx"
                   ECHO( Office 2016:              Not needed, all packages are language neutral or automatically chosen.
                   PAUSE
                   EXIT /B
               ) else (
                   SET "!optLong!=%~2"
                   SHIFT /1
               )
               GOTO :breakEvalOpt
           )
       )
    )
    :breakEvalOpt
    IF not "%~1"=="" (
       SHIFT /1
       GOTO :EvalOpt
    )
    FOR %%A in ( "dirOfEXE" "dirOfMSP" ) do (
           SET "optVital=%%~A"
           IF not defined !optVital! (
               ECHO(Please enter data for '!optVital!' of your Office Updates"
               SET /p "!optVital!=!optVital!:"
               ECHO(
           )
           If "!%%~A!"=="" (
               ECHO(Error: Can't continue because of empty var: '!optVital!'^^!
               PAUSE
               EXIT /b
           )
       )
    )
    
    
    DIR /a-d /s "!dirOfEXE!\*-*-*-*-*.exe" >NUL 2>&1
    IF not !ERRORLEVEL! equ 0 (
       ECHO(ERROR: Folder or valid named Office update files could not be found at "!dirOfEXE!\"^^!
    ) else (
       CD /d "!dirOfEXE!\"
       IF not exist "!dirOfMSP!\" ( MKDIR "!dirOfMSP!" )
       FOR /r %%A in ("*-*-*-*-*.exe") do (
           PUSHD "%%~dpA"
           SET "fileOfEXE=%%~nA"
           ECHO(Extracting "!fileOfEXE!.exe"
           "!fileOfEXE!.exe" /quiet /extract:"!dirOfMSP!\!fileOfEXE!"
           IF not exist "!dirOfMSP!\!fileOfEXE!\" (
               SET "ercFailEXE=!ERRORLEVEL!"
               SET /a "cntFailEXE+=1"
               SET "excFailEXE!cntFailEXE!=%%~fA"
               SET "ercFailEXE!cntFailEXE!=!ercFailEXE!"
               ECHO(ERROR: No folder was made after executing "!fileOfEXE!.exe"^^!
           ) else (
               PUSHD "!dirOfMSP!\!fileOfEXE!\"
               ECHO(=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
               FOR /r %%B in ("*.msp") do (
                   SET "fileOfMSP=%%~nB"
                   FOR /f "delims=-" %%C in ( "!fileOfMSP!" ) do (
                       SET "nameOfMSP=%%C"
                       SET "TRUE="
                       IF "LANG"=="" (
                           SET "TRUE=1"
                       ) else (
                           IF "!fileOfMSP!"=="!nameOfMSP!-x-none" (
                               SET "TRUE=1"
                           ) ELSE (
                               FOR %%D in ( !ProofLang! ) do (
                                   IF "!fileOfMSP!"=="proof-%%D" ( SET "TRUE=1" )
                               )
                               IF "!fileOfMSP!"=="!nameOfMSP!-!langOfMSP!" ( SET "TRUE=1" )
                           )
                       )
                       IF defined TRUE (
                           FOR /f "tokens=1-2,4 delims=-" %%D in ( "!fileOfEXE!" ) do (
                               SET "nameOfEXE=%%D"
                               SET "kbOfEXE=%%E"
                               SET "archOfEXE=%%F"
                           )
                           ECHO(Moving "!fileOfMSP!.msp" to "!dirOfMSP!\Z_!nameOfEXE!_!kbOfEXE!_!archOfEXE!_!fileOfMSP!.msp"
                           MOVE "!fileOfMSP!.msp" "!dirOfMSP!\Z_!nameOfEXE!_!kbOfEXE!_!archOfEXE!_!fileOfMSP!.msp"
                       )
                   )
               )
               ECHO(=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
               POPD
               ECHO(Removing folder "!dirOfMSP!\!fileOfEXE!\"
               RD /s /q "!dirOfMSP!\!fileOfEXE!\"
           )
           POPD
           ECHO(
       )
       ECHO(
       IF defined ercFailEXE (
           ECHO(A number of !cntFailEXE! executables have failed to extract folders.
           ECHO(The following have failed:
           FOR /L %%A in (1,1,!cntFailEXE!) Do (
               ECHO(
               ECHO(File: "!excFailEXE%%A!"
               ECHO(Errorcode: "!ercFailEXE%%A!"
           )
       ) else (
           ECHO(Dinner is ready^^!
       )
    )
    
    ECHO(
    ECHO(
    ECHO(Written and maintained by Hearlywarlot
    ECHO(For updates on the script or other nice things visit our awesome Forum at:
    ECHO(forums.mydigitallife.net/posts/1318798
    ECHO(
    
    ENDLOCAL
    PAUSE
    EXIT /b
    ----- Begin wsf script --->
    <package>
       <job id="ELAV">
           <script language="VBScript">
               Set strArg=WScript.Arguments.Named
    
               If Not strArg.Exists("File") Then
                   Wscript.Echo "Switch /File:<File> is missing."
                   WScript.Quit 1
               End If
    
               Set strRdlproc = CreateObject("WScript.Shell").Exec("rundll32 kernel32,Sleep")
               With GetObject("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" & strRdlproc.ProcessId & "'")
                   With GetObject("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" & .ParentProcessId & "'")
                       If InStr (.CommandLine, WScript.ScriptName) <> 0 Then
                           strLine = Mid(.CommandLine, InStr(.CommandLine , "/File:") + Len(strArg("File")) + 8)
                       End If
                   End With
                   .Terminate
               End With
    
               CreateObject("Shell.Application").ShellExecute "cmd", "/c " & chr(34) & chr(34) & strArg("File") & chr(34) & " " & strLine & chr(34), "", "runas", 1
           </script>
       </job>
    </package>

    Code:
    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION
    
    FSUTIL dirty query "!SYSTEMDRIVE!" >nul
    IF not !ERRORLEVEL! equ 0 (
        ( ECHO SET UAC = CreateObject^("Shell.Application"^)
            ECHO UAC.ShellExecute "%~dpf0", ELAV, "", "runas", 1
        )> "!TEMP!\OEgetPrivileges.vbs"
        "!TEMP!\OEgetPrivileges.vbs"
        DEL "!TEMP!\OEgetPrivileges.vbs"
        EXIT /B
    )
    
    SET "UPDFOL=E:\WHDownloader\Updates\Office2013-x86"
    SET "MSPFOL=!UPDFOL!\updates"
    SET "LANG=en-us"
    
    IF not defined UPDFOL (
        ECHO Please enter the path containing your Office Updates in script"
    ) else (
        IF not exist "!UPDFOL!\" (
            ECHO Could not find "!UPDFOL!\"
        ) else (
            IF not defined MSPFOL (
                ECHO Please enter the path where the MSP will be extracted to in script"
            ) else (
                CD /D "!UPDFOL!"
                MKDIR "!MSPFOL!"
                For /R %%A in (*.exe) do (
                    PUSHD "%%~dpA"
                    ECHO Extracting %%~xnA
                    SET "KBFIL=%%~nA"
                    "!KBFIL!.exe" /quiet /EXTRACT:"!KBFIL!"
                    IF exist "!KBFIL!\" (
                        PUSHD "!KBFIL!"
                        ECHO Moving MSP %%~xnA
                        For /R %%B in (*.msp) do (
                            SETLOCAL
                            IF "!LANG!" ==  "" (
                                SET "TRUE=1"
                            ) else (
                                SET "RMLNG1=%%~nB"
                                CALL SET "RMLNG=%%RMLNG1:-!RMLNG1:*-=!=%%"
                                IF "!RMLNG1!" ==  "!RMLNG!-x-none" (
                                    SET "TRUE=1"
                                ) else (
                                    IF "!RMLNG1!" ==  "!RMLNG!-!LANG!" (
                                        SET "TRUE=1"
                                    )
                                )
                            )
                            IF "!TRUE!" == "1" (
                                SET "MSPKB1=!KBFIL:*kb=KB!"
                                SET "MSPKB2=!MSPKB1:*-=!"
                                CALL SET "MSPKB=%%MSPKB1:-!MSPKB2!=%%"
                                SET "MSPARC1=!MSPKB2:*-=!"
                                SET "MSPARC=!MSPARC1:-glb=!"
                                MOVE "%%~nxB" "!MSPFOL!\Z_!MSPKB!_!MSPARC!_%%~nxB"
                            )
                            ENDLOCAL
                        )
                        POPD
                    )
                    RD /S /Q "!KBFIL!"
                    CLS
                    POPD
                )
            )
        )
    )
    
    ECHO Opening "!MSPFOL!"...
    EXPLORER "!MSPFOL!"
    ECHO Dinner is ready^^!
    
    PAUSE
    EXIT /B

    Changelog:
    Fixed some mistakes and added new features:
    • Script will now move out old MSP files to folder of choice as it copies your newer in.
    • Now has a additional parameter for configuring where old MSP files go to.
    • Will skip moving file if already exists at destination.
    • If a Office KB file does not contain any MSP files corresponding with your choice, the script will tell you (eg, imeloc2010).
    • Command Prompt window will resize and increase buffer a good bit to fit the onslaught of text, so you can read easier.
    • Replaced URL in script with URL to this thread, forgot it still linked to abbodi1406's post.
    I did an accident :wacko::
    • At the MSP lang check, I accidentally did not add '!' around "nameOfMSP", making lang checks fail... I fixed this now.
    • Made the script now only accept EXE files with a Office update naming convention such as "*-*-*-*-*.exe".
    Made some minor changes and fixes to the script.
    • You can now pass options in any order without being prompted to enter the data.
    • Because of Office 2016 being language neutral, "langOfMSP" and "Prooflang" are now optional.
    • Included credit and url to this thread at the end of the script.
    • Will list which EXE files failed to extract folders.
    Update: Made a major edit of the script.
    The script now has the following changes:
    • Supports Unix like options and has a nice help display.
    • Will ask for the required data if any of the variables needed are missing.
    • Embedded Elevation VBS is run without TMP files.
    • Proof languages can be defined.
    • Made the code much easier to read and understand.
    • Made the output more fancy looking.
    First release of script.


    Your welcome ^^.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Rootz

    Rootz MDL Novice

    Apr 8, 2008
    17
    3
    0
    First of all, thanks for the good work :worthy:

    I´ve a request for your batch.
    It´s possible to add a option to have Office Updates filter a language?

    In WHDownloader íve this option:

    MSPLangFilter=pt-pt
     
  3. hearywarlot

    hearywarlot MDL Member

    Jul 31, 2015
    105
    98
    10
    #3 hearywarlot, Sep 9, 2015
    Last edited: Sep 9, 2015
    (OP)
    Fresh scripts! Go get your script while it is still warm!
    Your wish has been fullfilled, I have also updated the 'Usage:' section, so check that out if you need info on how to use the added poison.

    Have a nice day ^^.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Rootz

    Rootz MDL Novice

    Apr 8, 2008
    17
    3
    0
    It works great now! :worthy:
     
  5. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    699
    394
    30
    Thanks for all ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. compstuff

    compstuff MDL Senior Member

    Jan 16, 2011
    437
    310
    10
    Absolutely love this script!!! THANKS!!!
     
  7. Mr.X

    Mr.X MDL Guru

    Jul 14, 2013
    5,562
    12,987
    180
  8. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    7,149
    21,886
    240
    No

    only proof files need to be kept

    you can use 7-zip to extract them
     
  9. Mr.X

    Mr.X MDL Guru

    Jul 14, 2013
    5,562
    12,987
    180
    Okay, so it is fine to apply in ANY order all proof files first over any other msp file?
     
  10. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    7,149
    21,886
    240
    Yes, each file is a separate patch
     
  11. SLG

    SLG MDL Novice

    Oct 7, 2015
    7
    5
    0
    #11 SLG, Feb 18, 2017
    Last edited: Feb 19, 2017
    "This is a batch script which will allow you to easily extract Office MSP files automatically from a dir to a 'updates' folder."

    These .msp are intended to be copied to folder Update in DVD or i should create a install script?


    Sorry for the silly question, google tell me the answer. i just go to install and check now.

    Thanks for share this is a great help.


    Finally installed. Office 20013 Sp1 with updates until january 2017, here the log:
    Installation settings: default
    Installation time 1h30min
    110 hoxfixes reported installed by windows update
    iso grow to 3.1 Gb
    all working as should

    Thanks again for post this batch and thanks to VHdownloader.
     
  12. hearywarlot

    hearywarlot MDL Member

    Jul 31, 2015
    105
    98
    10
    Update: Made a major edit of the script.

    The script now has the following changes:
    • Supports Unix like parameters and has a nice help display.
    • Will ask for the required data if any of the variables needed are missing.
    • Embedded Elevation VBS is run without TMP files.
    • Proof languages can be defined.
    • Made the code much easier to read and understand.
    • Made the output more fancy looking.
    See if you like it and if you find any bugs, please post it so I can try fix it :).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    12,346
    13,442
    340
    Code:
    Extracted by WHD itself:
    Settings:
    
    DownloadPath=F:\WHDownloader_0.0.2.2\
    ExtractMSPPath=F:\WHDownloader_0.0.2.2\MSP's\
    ExtractMSP=True
    MSPLangFilter=
    
    Files:
    cd90fc695ad9e4a1110e2f11a02845db20304712 *access-x-none.msp
    84c4a1ddb0b3f80fb022880bdd4786db61f6d145 *ace-x-none.msp
    d6b1b647cdd150068d62ba8e1c2102a14222449f *chart-x-none.msp
    3b13e9c84e7abaaf32c1ced1d03f11e64b48d58b *conv-x-none.msp
    f829fd9dc8fa0704cf6a119642f5d1aaa3cd5f60 *csisyncclient-x-none.msp
    1e97ff955c6db76016367994e0d7b1967155976d *csi-x-none.msp
    f5386c5e896d5f28833be73e8a9ca8ad3966176e *dcf-x-none.msp
    208891f03b5c14a73fb69c03f94f986a3b25539a *excelpp-x-none.msp
    cbf4b376ad0555ada516d58e47c7bf6046689155 *excel-x-none.msp
    e45e6c509c4e500d275a261149e2f8e0af2587d2 *exppdf-x-none.msp
    e336cbd33d9339a7f93973e3a752806c7ed725c0 *filterpack-x-none.msp
    9a5b04688c0774afb9e78aa5299763c1724fbb3d *fonts-x-none.msp
    0036eff2d0080a144faf550c5c91f1d7bb7ddf6d *gkall-x-none.msp
    c74201f3fd00de07d3e2b2177c38fc9d747ac57e *groove-x-none.msp
    c380ae56653130f0fc6c7cb7d15b9e6b987f24ab *ieawsdc-x-none.msp
    da8e1693e896995b0adaf2bfeb9e9e7f1fdb6049 *kohhc-x-none.msp
    90f6638837b719e1bf84aa46b4d27ac006d863f1 *lync-x-none.msp
    ba36a5d4c731674b279c691ce70c6391dace8537 *msmipc-x-none.msp
    1106e547c956e49b29501798ae5007916031109a *msodll20-x-none.msp
    bf75e87cd34914c82c46aa039405a60824c8e46a *msodll30-x-none.msp
    214511812cf1cc318221824579f69a101af129b5 *msodll40ui-x-none.msp
    550e76920548f01c41c01e0d1a36ed9d62d9850d *msodll99l-x-none.msp
    4d3f17df314f952a339faee86e3f68f6af250636 *mso-x-none.msp
    42a6a9ceaebc0b8bba375d947b8ebe4409529e73 *oart-x-none.msp
    d3c18e69e5296b54fe419f0adbd63983a3a77f34 *oleo-x-none.msp
    acfc67b56597f92e5a69afd2200fa6316684fd95 *onenote-x-none.msp
    e1800f796113fa085153eb7c64449422c524b7ba *orgidcrl-x-none.msp
    917b37c70fba26b23b3d17a2fbab3f9087689f9d *osfclient-x-none.msp
    de7e050844f6fa67b37eb3e2efd830312e4fd9b3 *ospp-x-none.msp
    422c21d8f8653023c00e57d0d8824d23090a8159 *outexum-x-none.msp
    083af21a71e9394666a7af272311fbdd8edfa783 *outlfltr-x-none.msp
    0f9dc9c38ff1ec435afcd7ad099688477adb6339 *outlook-x-none.msp
    f127e986cdc74b465e8a52badef620399b703c7b *policytips-x-none.msp
    df4872b376a29b326a51f11e2c8edab5334cb23d *powerpoint-x-none.msp
    954e981a4eb763249fc6422b750edfb84908b44e *ppaddin-x-none.msp
    ee3e2bd3f878941e6e8a2a9f40b0b3247e24f061 *project-x-none.msp
    02b2896fac9e6c0a01138d2dcfafc25120eede6b *proof-x-none.msp
    468ecec3d97f19afb56c404b282ed90c391f9c3d *protocolhndlr-x-none.msp
    697c18574db3f4bdbf620fed4cfa48e7bd0eecf7 *publisher-x-none.msp
    4e3af12925944d0cd60b1e9d0f9710ede86650c0 *riched20-x-none.msp
    d1d35be4e676495531b130eee7c564a633a9f9e0 *stslist-x-none.msp
    b3f38ee1773d4effa918b0b851c1588ecb4fcd6d *stsupld-x-none.msp
    2f941b6e12e0f8d0d3c3baa2a3ab89f11736eeea *vbe7-x-none.msp
    648f58d62bdb5da852d78e12ee5cac4b5c93c461 *visio-x-none.msp
    b25a551d4b8bc5dbf9bc17b3863dbb005e3922d0 *word-x-none.msp
    a93c4cb9002dc6681146f7f9c298a74fefa5fec9 *wxpcore-x-none.msp
    44b5f982040acb84e49e375ab20a8b1a39dfdcde *wxpnse-x-none.msp
    
    
    Code:
    Your script set to nl + companion proofing langs
    
    SET "dirOfExe=f:\WHDownloader_0.0.2.2\Updates\Office2016-x64\"
    SET "dirOfMsp=%~dp0MSPs"
    SET "langOfMSP=nl-NL"
    SET "ProofLang=fr-fr,de-de,en-us"
    
    Files:
    cd90fc695ad9e4a1110e2f11a02845db20304712 *Z_access2016_kb3178700_x64_access-x-none.msp
    84c4a1ddb0b3f80fb022880bdd4786db61f6d145 *Z_ace2016_kb3115501_x64_ace-x-none.msp
    d6b1b647cdd150068d62ba8e1c2102a14222449f *Z_chart2016_kb3191867_x64_chart-x-none.msp
    3b13e9c84e7abaaf32c1ced1d03f11e64b48d58b *Z_conv2016_kb3114375_x64_conv-x-none.msp
    1e97ff955c6db76016367994e0d7b1967155976d *Z_csi2016_kb3191862_x64_csi-x-none.msp
    f829fd9dc8fa0704cf6a119642f5d1aaa3cd5f60 *Z_csisyncclient2016_kb3118264_x64_csisyncclient-x-none.msp
    f5386c5e896d5f28833be73e8a9ca8ad3966176e *Z_dcf2016_kb2910990_x64_dcf-x-none.msp
    cbf4b376ad0555ada516d58e47c7bf6046689155 *Z_excel2016_kb3191861_x64_excel-x-none.msp
    208891f03b5c14a73fb69c03f94f986a3b25539a *Z_excelpp2016_kb3128050_x64_excelpp-x-none.msp
    e45e6c509c4e500d275a261149e2f8e0af2587d2 *Z_exppdf2016_kb2920720_x64_exppdf-x-none.msp
    e336cbd33d9339a7f93973e3a752806c7ed725c0 *Z_filterpack2016_kb2920684_x64_filterpack-x-none.msp
    9a5b04688c0774afb9e78aa5299763c1724fbb3d *Z_fonts2016_kb3114903_x64_fonts-x-none.msp
    0036eff2d0080a144faf550c5c91f1d7bb7ddf6d *Z_gkall2016_kb3115276_x64_gkall-x-none.msp
    c74201f3fd00de07d3e2b2177c38fc9d747ac57e *Z_groove2016_kb3141458_x64_groove-x-none.msp
    c380ae56653130f0fc6c7cb7d15b9e6b987f24ab *Z_ieawsdc2016_kb3085538_x64_ieawsdc-x-none.msp
    da8e1693e896995b0adaf2bfeb9e9e7f1fdb6049 *Z_kohhc2016_kb3178692_x64_kohhc-x-none.msp
    90f6638837b719e1bf84aa46b4d27ac006d863f1 *Z_lync2016_kb3191858_x64_lync-x-none.msp
    ba36a5d4c731674b279c691ce70c6391dace8537 *Z_msmipc2016_kb3178666_x64_msmipc-x-none.msp
    4d3f17df314f952a339faee86e3f68f6af250636 *Z_mso2016_kb3191881_x64_mso-x-none.msp
    1106e547c956e49b29501798ae5007916031109a *Z_msodll202016_kb3127991_x64_msodll20-x-none.msp
    bf75e87cd34914c82c46aa039405a60824c8e46a *Z_msodll302016_kb3178703_x64_msodll30-x-none.msp
    214511812cf1cc318221824579f69a101af129b5 *Z_msodll40ui2016_kb3178706_x64_msodll40ui-x-none.msp
    550e76920548f01c41c01e0d1a36ed9d62d9850d *Z_msodll99l2016_kb3191863_x64_msodll99l-x-none.msp
    42a6a9ceaebc0b8bba375d947b8ebe4409529e73 *Z_oart2016_kb3191857_x64_oart-x-none.msp
    d3c18e69e5296b54fe419f0adbd63983a3a77f34 *Z_oleo2016_kb2910970_x64_oleo-x-none.msp
    acfc67b56597f92e5a69afd2200fa6316684fd95 *Z_onenote2016_kb3141512_x64_onenote-x-none.msp
    e1800f796113fa085153eb7c64449422c524b7ba *Z_orgidcrl2016_kb2920712_x64_orgidcrl-x-none.msp
    917b37c70fba26b23b3d17a2fbab3f9087689f9d *Z_osfclient2016_kb3178658_x64_osfclient-x-none.msp
    de7e050844f6fa67b37eb3e2efd830312e4fd9b3 *Z_ospp2016_kb2920724_x64_ospp-x-none.msp
    422c21d8f8653023c00e57d0d8824d23090a8159 *Z_outexum2016_kb3141506_x64_outexum-x-none.msp
    083af21a71e9394666a7af272311fbdd8edfa783 *Z_outlfltr2016_kb3115407_x64_outlfltr-x-none.msp
    0f9dc9c38ff1ec435afcd7ad099688477adb6339 *Z_outlook2016_kb3191883_x64_outlook-x-none.msp
    f127e986cdc74b465e8a52badef620399b703c7b *Z_policytips2016_kb3115081_x64_policytips-x-none.msp
    df4872b376a29b326a51f11e2c8edab5334cb23d *Z_powerpoint2016_kb3191860_x64_powerpoint-x-none.msp
    954e981a4eb763249fc6422b750edfb84908b44e *Z_ppaddin2016_kb3141454_x64_ppaddin-x-none.msp
    ee3e2bd3f878941e6e8a2a9f40b0b3247e24f061 *Z_project2016_kb3191870_x64_project-x-none.msp
    02b2896fac9e6c0a01138d2dcfafc25120eede6b *Z_proof2016_kb3141509_x64_proof-x-none.msp
    468ecec3d97f19afb56c404b282ed90c391f9c3d *Z_protocolhndlr2016_kb2910954_x64_protocolhndlr-x-none.msp
    697c18574db3f4bdbf620fed4cfa48e7bd0eecf7 *Z_publisher2016_kb3128047_x64_publisher-x-none.msp
    4e3af12925944d0cd60b1e9d0f9710ede86650c0 *Z_riched202016_kb3115100_x64_riched20-x-none.msp
    d1d35be4e676495531b130eee7c564a633a9f9e0 *Z_stslist2016_kb3114709_x64_stslist-x-none.msp
    b3f38ee1773d4effa918b0b851c1588ecb4fcd6d *Z_stsupld2016_kb2920678_x64_stsupld-x-none.msp
    2f941b6e12e0f8d0d3c3baa2a3ab89f11736eeea *Z_vbe72016_kb3115135_x64_vbe7-x-none.msp
    648f58d62bdb5da852d78e12ee5cac4b5c93c461 *Z_visio2016_kb3191856_x64_visio-x-none.msp
    b25a551d4b8bc5dbf9bc17b3863dbb005e3922d0 *Z_word2016_kb3191865_x64_word-x-none.msp
    a93c4cb9002dc6681146f7f9c298a74fefa5fec9 *Z_wxpcore2016_kb3118263_x64_wxpcore-x-none.msp
    44b5f982040acb84e49e375ab20a8b1a39dfdcde *Z_wxpnse2016_kb3118262_x64_wxpnse-x-none.msp
    
    
    I don't see any difference in the two sets?
     
  14. hearywarlot

    hearywarlot MDL Member

    Jul 31, 2015
    105
    98
    10
    Yup, that's right.
    Everything works as expected, what exactly is the problem between the two?
    Is it the naming convention I used for my script or is something missing.

    Please elaborate your issue.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    12,346
    13,442
    340
    The "problem" is, i would expect to see any difference, WHD is set to extract no specific language or any companion proofing languages.

    Your script is set to nl-NL + comp. proofing languages.

    But the extracted MSP files are exactly the same for both scripts.
     
  16. hearywarlot

    hearywarlot MDL Member

    Jul 31, 2015
    105
    98
    10
    #16 hearywarlot, May 21, 2017
    Last edited: May 21, 2017
    (OP)
    If you mean it like that, then yes, you need to set the variables.
    I set no preset in the code except for the variables because there is no point as you need to set one anyway for it to be useful.
    I could make a exception to Proofing language variable, but someday you might need it and you might forget this.

    Do you perhaps mean you want to extract multiple languages at once?

    You can easily extract MSP of separate languages to different folders by executing the script in a command with options.
    For example:
    Code:
    extract_slipstream_office.cmd --dirOfEXE "f:\WHDownloader_0.0.2.2\Updates\Office2016-x64" --dirOfMSP "f:\NL_2016_x64_MSPs" --langOfMSP "nl-nl" --ProofLang="en-us,fr-fr,de-de"
    extract_slipstream_office.cmd --dirOfEXE "f:\WHDownloader_0.0.2.2\Updates\Office2016-x64" --dirOfMSP "f:\EN_2016_x64_MSPs" --langOfMSP "en-us" --ProofLang="fr-fr,es-es"
    Otherwise, both do their job just fine.
    Mine is useful if you were to want to extract existing folder of patches or do quick Batch jobs for multiple languages.
    Also not sure if WHDownloader does anything with this, but mine also supports Proofing companions.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    12,346
    13,442
    340
    You don't understand, would setting different languages and their companion proofing languages extract different msp's with each new language setting?

    In 2010 and 2013 office there are different msp's extracted but with 2016 i always get the exact same msp's, not any showing a language code like with office 2010 and 2013.
     
  18. hearywarlot

    hearywarlot MDL Member

    Jul 31, 2015
    105
    98
    10
    I checked the contents of all 44 currently available though WHDownloader downloadable 2016 x64 patches and they are all language neutral.
    There looks to be no problem, the x-none suffix you see is as expected.

    If you still see a problem, you may check contents the patches yourself to see if I missed anything, but I am fairly sure it's all fine.

    Thanks for your help.
    if you find any bugs, don't hesitate to tell me :).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    12,346
    13,442
    340
    But then the language codes plus proofing companion settings are not really needed for updating the Office 2016 iso's,

    I could use one set of extracted MSP files to update all different Office 2016 lso's in all languages.
     
  20. hearywarlot

    hearywarlot MDL Member

    Jul 31, 2015
    105
    98
    10
    Maybe so, but it's fine.
    The script was written to work with any Office patch that may ever come out.

    But since 2016 has no languages and Proofing is not there I will allow to set language and proofing as empty again :).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...