Loop through folder of multiple wim's

Discussion in 'Windows 8' started by hypedave, Nov 11, 2014.

  1. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    #81 hypedave, Nov 19, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Retrying it now.

     
  2. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #82 s1ave77, Nov 19, 2014
    Last edited by a moderator: Apr 20, 2017
    Complete script with all changes:

    Code:
    @echo off
    :: get admin rights
    (NET FILE||(powershell -command Start-Process '%0' -Verb runAs -ArgumentList '%* '&EXIT /B))>NUL 2>&1
    setLocal EnableDelayedExpansion
    
    :: Get timestamp data: will show month.day.year.hour.min.sec
    for /f "skip=1 delims=" %%x in ('wmic os get localdatetime') do if not defined X set X=%%x
    :: Timestamp with seconds
    :: set timestamp=%X:~4,2%-%X:~6,2%-%X:~0,4%-%X:~8,2%-%X:~10,2%-%X:~12,2%
    :: Timestamp without seconds
    set timestamp=%X:~4,2%-%X:~6,2%-%X:~0,4%-%X:~8,2%-%X:~10,2%
    :: Path to update packages
    set updates1=e:\windowsupdates\Baseline
    set updates2=e:\windowsupdates\General
    set updates3=e:\windowsupdates\Hotfix
    set updates4=e:\windowsupdates\Security
    set updates5=e:\windowsupdates\Additional
    set updates6=e:\windowsupdates\Extra
    :: Exclude WIms from 
    set textfile=e:\wim\exclusions.txt
    
    :: CHECK FOR FILES TO PROCESS OR EXIT
    :: set compare files
    set "wimfile=e:\wim\wimlist.txt"
    set "deltafile=e:\wim\deltalist.txt"
    if exist %wimfile% del /s /q %wimfile% >nul
    if exist %deltafile% del /s /q %deltafile% >nul
    :: get WIM names from Folder
    for /r "e:\wim" %%a in (*.wim) do echo %%~na>>%wimfile%
    :: compare files and write difference to %deltafile%
    for /f "tokens=1 delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %textfile%) -DifferenceObject (Get-Content %wimfile%) ^| Format-Table -AutoSize" ^| findstr /i "=^>"') do echo %%a>>%deltafile%
    if not exist %deltafile% (
    echo No files to process found.
    echo:
    pause
    if exist %wimfile% del /s /q %wimfile% >nul
    exit
    )
    
    :: Path to files copy
    set path1=e:\files
    set target=e:\mount
    
    :: start procedure
    :: backup all WIMs to e:\backup\backup.wim
    echo.
    echo ===============================================================================
    echo Backing up to e:\backup\backup_%timestamp%.wim
    echo ===============================================================================
    echo.
    set "p=0"
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Exporting %%a to e:\backup\backup.wim
    echo.
    Dism /Export-Image /SourceImageFile:e:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:e:\backup\backup_%timestamp%.wim /compress:max /CheckIntegrity
    )
    :: mount single WIMs to e:\mount, add updates and unmount/commit
    echo.
    echo ===============================================================================
    echo Mounting to e:\mount
    echo Adding Updates
    echo Unmount/Commit
    echo ===============================================================================
    echo.
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates1%" %%a in (*.*) do set /a a+=1
    for /r "%updates2%" %%a in (*.*) do set /a b+=1
    for /r "%updates3%" %%a in (*.*) do set /a c+=1
    for /r "%updates4%" %%a in (*.*) do set /a d+=1
    for /r "%updates5%" %%a in (*.*) do set /a e+=1
    for /r "%updates6%" %%a in (*.*) do set /a f+=1
    :: execute loop for deltas only
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Processing %%a
    echo.
    DISM /mount-wim /wimfile:e:\wim\%%a.wim /index:1 /mountdir:e:\mount
    if /i %a% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%
    if /i %b% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%
    if /i %c% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%
    if /i %d% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%
    if /i %e% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%
    if /i %f% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%
    xcopy.exe %path1%\*.* %target%\*.* /s /d /e /h /r /y
    DISM /unmount-wim /mountdir:e:\mount /commit
    echo %%a>>%textfile%
    )
    :: merge single WIMs to e:\master\install.wim
    echo.
    echo ===============================================================================
    echo Exporting to e:\master
    echo ===============================================================================
    echo.
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Exporting %%a to e:\master\install.wim
    echo.
    Dism /Export-Image /SourceImageFile:e:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:e:\master\install.wim /compress:max /CheckIntegrity
    )
    if exist %wimfile% del /s /q %wimfile% >nul
    if exist %deltafile% del /s /q %deltafile% >nul
    
    :: split master WIM
    echo.
    echo ===============================================================================
    echo Splitting WIM to e:\sources
    echo ===============================================================================
    echo.
    Dism /Split-Image /ImageFile:e:\master\install.wim /SWMFile:e:\sources\install.swm /FileSize:256
    
    :: end procedure
    :: script will pause here
    echo.
    echo ===============================================================================
    echo DONE ...
    echo ===============================================================================
    echo.
    pause
    
    :: EXIT
    endlocal
    exit
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Seems this solution errors only if name exceeds 76 chars, should be sufficient in most cases.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    Ok i'll have another bone to throw at you tonight. Exclude updates based on text in wim file name. Let me think this one through on how I want you to code it up.
     
  5. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Does that mean it works now :g:?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #86 s1ave77, Nov 20, 2014
    Last edited by a moderator: Apr 20, 2017
    As a char limit s*cks ... here a so far limitless solution (tested with 344 char file names, pointless for file names but cool for other purposes):


    Code:
    set "psfile=%temp%\compare.ps1"
    echo Compare-Object -ReferenceObject ^(Get-Content e:\wim\exclusions.txt^) -DifferenceObject ^(Get-Content e:\wim\wimlist.txt^) ^| where-object SideIndicator -eq "=>" ^| select -Expand InputObject ^| fl>%psfile%
    for /f "tokens=1 delims= " %%a in ('powershell -ExecutionPolicy Bypass -File %psfile%') do echo %%a>>%deltafile%
    if exist %psfile% del /s /q %psfile% >nul
    
    now test script (i worked with text files only) outputs:
    Code:
    Delta:
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0001-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0001-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0001
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0001-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0001-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0001-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0003-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0003-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0003
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0003-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0003-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0003-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0007-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0007-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0007
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0007-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0007-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0007-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0008-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0008-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0008
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0008-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0008-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0008-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0009-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0009-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0009
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0009-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0009-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0009-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0012-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0012-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0012
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0012-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0012-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0012-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0013-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0013-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0013
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0013-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0013-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0013-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0016-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0016-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0016
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0016-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0016-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0016-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0015-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0015-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0015
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0015-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0015-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0015-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0017-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0017-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0017
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0017-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0017-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0017-11-17-2014
    ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0018-11-17-2014ABCDE_12345678_XXXX_XXX
    _XXXXX_XX_XXX_XXXX_0018-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0018
    -11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XXX_XXXX_0018-11-17-2014ABCDE_123456
    78_XXXX_XXX_XXXXX_XX_XXX_XXXX_0018-11-17-2014ABCDE_12345678_XXXX_XXX_XXXXX_XX_XX
    X_XXXX_0018-11-17-2014
    
    ===============================================================================
    DONE ...
    ===============================================================================
    
    Drücken Sie eine beliebige Taste . . .
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    Yes it works great right now, still havent thrown it to the wolves by testing 50 various wims yet. Just wondering right now whats the current character limit. I'm cleaning up the Windowsupdate folder now so I can visualize my last and final challenge.

     
  8. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #88 s1ave77, Nov 20, 2014
    Last edited by a moderator: Apr 20, 2017
    As i was working on an own compare solution, i realized, the way i used (with additional EXE) was unreliable, so it was a nice challenge :good3:.

    Problem with powershell was, that sometimes it shows '=>' and '<=', so deltafile is incorrect. The output way as table was easy to handle the directions but cuts the output at a certain point.

    So it needed to find that

    Code:
    | where-object SideIndicator -eq "=>" | select -Expand InputObject | fl
    only shows differences in one way and due to formatting as list only the name value without any cutting :cool2:.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    #89 hypedave, Nov 20, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Okay here we next the last issue.

    :worthy:

    Apply Updates Package based up check in wimfile name

    If WIM file containts "w7sp1x64" get updates from package group 1
    If WIM file containts "w7sp1x86" get updates from package group 2
    If WIM file containts "w8x64" get updates from package group 3
    If WIM file containts "w8x86" get updates from package group 4
    If WIM file containts "w81u1x64" get updates from package group 5
    If WIM file containts "w81u1x86" get updates from package group 6

    See code

    Code:
    @echo off
    :: get admin rights
    (NET FILE||(powershell -command Start-Process '%0' -Verb runAs -ArgumentList '%* '&EXIT /B))>NUL 2>&1
    setLocal EnableDelayedExpansion
    
    :: Get timestamp data: will show month.day.year.hour.min.sec
    for /f "skip=1 delims=" %%x in ('wmic os get localdatetime') do if not defined X set X=%%x
    :: Timestamp with seconds
    :: set timestamp=%X:~4,2%-%X:~6,2%-%X:~0,4%-%X:~8,2%-%X:~10,2%-%X:~12,2%
    :: Timestamp without seconds
    set timestamp=%X:~4,2%-%X:~6,2%-%X:~0,4%-%X:~8,2%-%X:~10,2%
    :: Path to update packages group 1
    set updates01=E:\updates\Windows7-x64\Baseline
    set updates02=E:\updates\Windows7-x64\General
    set updates03=E:\updates\Windows7-x64\Hotfix
    set updates04=E:\updates\Windows7-x64\Security
    set updates05=E:\updates\Windows7-x64\Additional
    set updates06=E:\updates\Windows7-x64\Extra
    :: Path to update packages group 2
    set updates07=E:\updates\Windows7-x86\Baseline
    set updates08=E:\updates\Windows7-x86\General
    set updates09=E:\updates\Windows7-x86\Hotfix
    set updates10=E:\updates\Windows7-x86\Security
    set updates11=E:\updates\Windows7-x86\Additional
    set updates12=E:\updates\Windows7-x86\Extra
    :: Path to update packages group 3
    set updates13=E:\updates\Windows8-x64\Baseline
    set updates14=E:\updates\Windows8-x64\General
    set updates15=E:\updates\Windows8-x64\Hotfix
    set updates16=E:\updates\Windows8-x64\Security
    set updates17=E:\updates\Windows8-x64\Additional
    set updates18=E:\updates\Windows8-x64\Extra
    :: Path to update packages group 4
    set updates19=E:\updates\Windows8-x86\Baseline
    set updates20=E:\updates\Windows8-x86\General
    set updates21=E:\updates\Windows8-x86\Hotfix
    set updates22=E:\updates\Windows8-x86\Security
    set updates23=E:\updates\Windows8-x86\Additional
    set updates24=E:\updates\Windows8-x68\Extra
    :: Path to update packages group 5
    set updates26=E:\updates\Windows8.1-x64\Baseline
    set updates27=E:\updates\Windows8.1-x64\General
    set updates28=E:\updates\Windows8.1-x64\Hotfix
    set updates29=E:\updates\Windows8.1-x64\Security
    set updates30=E:\updates\Windows8.1-x64\Additional
    set updates31=E:\updates\Windows8.1-x64\Extra
    :: Path to update packages group 6
    set updates32=E:\updates\Windows8.1-x86\Baseline
    set updates33=E:\updates\Windows8.1-x86\General
    set updates34=E:\updates\Windows8.1-x86\Hotfix
    set updates35=E:\updates\Windows8.1-x86\Security
    set updates36=E:\updates\Windows8.1-x86\Additional
    set updates37=E:\updates\Windows8.1-x86\Extra
    :: Exclude WIms from 
    set textfile=e:\wim\exclusions.txt
    
    :: CHECK FOR FILES TO PROCESS OR EXIT
    :: set compare files
    set "wimfile=e:\wim\wimlist.txt"
    set "deltafile=e:\wim\deltalist.txt"
    if exist %wimfile% del /s /q %wimfile% >nul
    if exist %deltafile% del /s /q %deltafile% >nul
    :: get WIM names from Folder
    for /r "e:\wim" %%a in (*.wim) do echo %%~na>>%wimfile%
    :: compare files and write difference to %deltafile%
    for /f "tokens=1 delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %textfile%) -DifferenceObject (Get-Content %wimfile%) ^| Format-Table -AutoSize" ^| findstr /i "=^>"') do echo %%a>>%deltafile%
    if not exist %deltafile% (
    echo No files to process found.
    echo:
    pause
    if exist %wimfile% del /s /q %wimfile% >nul
    exit
    )
    
    :: Path to files copy
    set path1=e:\files
    set target=e:\mount
    
    :: start procedure
    :: backup all WIMs to e:\backup\backup.wim
    echo.
    echo ===============================================================================
    echo Backing up to e:\backup\backup_%timestamp%.wim
    echo ===============================================================================
    echo.
    set "p=0"
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Exporting %%a to e:\backup\backup.wim
    echo.
    Dism /Export-Image /SourceImageFile:e:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:e:\backup\backup_%timestamp%.wim /compress:max /CheckIntegrity
    )
    :: mount single WIMs to e:\mount, add updates and unmount/commit
    echo.
    echo ===============================================================================
    echo Mounting to e:\mount
    echo Adding Updates
    echo Unmount/Commit
    echo ===============================================================================
    echo.
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates01%" %%a in (*.*) do set /a f+=1
    for /r "%updates02%" %%a in (*.*) do set /a f+=1
    for /r "%updates03%" %%a in (*.*) do set /a f+=1
    for /r "%updates04%" %%a in (*.*) do set /a f+=1
    for /r "%updates05%" %%a in (*.*) do set /a f+=1
    for /r "%updates06%" %%a in (*.*) do set /a f+=1
    for /r "%updates07%" %%a in (*.*) do set /a f+=1
    for /r "%updates08%" %%a in (*.*) do set /a f+=1
    for /r "%updates09%" %%a in (*.*) do set /a f+=1
    for /r "%updates10%" %%a in (*.*) do set /a f+=1
    for /r "%updates11%" %%a in (*.*) do set /a f+=1
    for /r "%updates12%" %%a in (*.*) do set /a f+=1
    for /r "%updates13%" %%a in (*.*) do set /a f+=1
    for /r "%updates14%" %%a in (*.*) do set /a f+=1
    for /r "%updates15%" %%a in (*.*) do set /a f+=1
    for /r "%updates16%" %%a in (*.*) do set /a f+=1
    for /r "%updates17%" %%a in (*.*) do set /a f+=1
    for /r "%updates18%" %%a in (*.*) do set /a f+=1
    for /r "%updates19%" %%a in (*.*) do set /a f+=1
    for /r "%updates20%" %%a in (*.*) do set /a f+=1
    for /r "%updates21%" %%a in (*.*) do set /a f+=1
    for /r "%updates22%" %%a in (*.*) do set /a f+=1
    for /r "%updates23%" %%a in (*.*) do set /a f+=1
    for /r "%updates24%" %%a in (*.*) do set /a f+=1
    for /r "%updates25%" %%a in (*.*) do set /a f+=1
    for /r "%updates26%" %%a in (*.*) do set /a f+=1
    for /r "%updates27%" %%a in (*.*) do set /a f+=1
    for /r "%updates28%" %%a in (*.*) do set /a f+=1
    for /r "%updates29%" %%a in (*.*) do set /a f+=1
    for /r "%updates30%" %%a in (*.*) do set /a f+=1
    for /r "%updates31%" %%a in (*.*) do set /a f+=1
    for /r "%updates32%" %%a in (*.*) do set /a f+=1
    for /r "%updates33%" %%a in (*.*) do set /a f+=1
    for /r "%updates34%" %%a in (*.*) do set /a f+=1
    for /r "%updates35%" %%a in (*.*) do set /a f+=1
    for /r "%updates36%" %%a in (*.*) do set /a f+=1
    for /r "%updates37%" %%a in (*.*) do set /a f+=1
    :: execute loop for deltas only
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Processing %%a
    echo.
    DISM /mount-wim /wimfile:e:\wim\%%a.wim /index:1 /mountdir:e:\mount
    if /i %a% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%
    if /i %b% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%
    if /i %c% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%
    if /i %d% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%
    if /i %e% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%
    if /i %f% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%
    xcopy.exe %path1%\*.* %target%\*.* /s /d /e /h /r /y
    powershell.exe remote-item %target%\lanrev* -recurse -force
    powershell.exe remote-item %target%\programdata\pole position software\lanrev agent\cacheddata\*.* -recurse -force
    
    DISM /unmount-wim /mountdir:e:\mount /commit
    echo %%a>>%textfile%
    )
    :: merge single WIMs to e:\master\install.wim
    echo.
    echo ===============================================================================
    echo Exporting to e:\master
    echo ===============================================================================
    echo.
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Exporting %%a to e:\master\install.wim
    echo.
    Dism /Export-Image /SourceImageFile:e:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:e:\master\install.wim /compress:max /CheckIntegrity
    )
    if exist %wimfile% del /s /q %wimfile% >nul
    if exist %deltafile% del /s /q %deltafile% >nul
    
    :: split master WIM
    echo.
    echo ===============================================================================
    echo Splitting WIM to e:\sources
    echo ===============================================================================
    echo.
    Dism /Split-Image /ImageFile:e:\master\install.wim /SWMFile:e:\sources\install.swm /FileSize:256
    
    :: end procedure
    :: script will pause here
    echo.
    echo ===============================================================================
    echo DONE ...
    echo ===============================================================================
    echo.
    pause
    
    :: EXIT
    endlocal
    exit
     
  10. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    What do the powershell commands exactly :g:?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    Oh my bad, deletes folder using wildcard characters, similiar to rmdir 9* /s /q
     
  12. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #92 s1ave77, Nov 20, 2014
    Last edited by a moderator: Apr 20, 2017
    Code:
    @echo off
    :: get admin rights
    (NET FILE||(powershell -command Start-Process '%0' -Verb runAs -ArgumentList '%* '&EXIT /B))>NUL 2>&1
    setLocal EnableDelayedExpansion
    
    :: Get timestamp data: will show month.day.year.hour.min.sec
    for /f "skip=1 delims=" %%x in ('wmic os get localdatetime') do if not defined X set X=%%x
    :: Timestamp with seconds
    :: set timestamp=%X:~4,2%-%X:~6,2%-%X:~0,4%-%X:~8,2%-%X:~10,2%-%X:~12,2%
    :: Timestamp without seconds
    set timestamp=%X:~4,2%-%X:~6,2%-%X:~0,4%-%X:~8,2%-%X:~10,2%
    :: Exclude WIms from 
    set textfile=e:\wim\exclusions.txt
    :: Path to update packages group 1
    set updates1=E:\updates\Windows7-x64
    :: Path to update packages group 2
    set updates2=E:\updates\Windows7-x86
    :: Path to update packages group 3
    set updates3=E:\updates\Windows8-x64
    :: Path to update packages group 4
    set updates4=E:\updates\Windows8-x86
    :: Path to update packages group 5
    set updates5=E:\updates\Windows8.1-x64
    :: Path to update packages group 6
    set updates6=E:\updates\Windows8.1-x86
    :: set compare files
    set "wimfile=e:\wim\wimlist.txt"
    set "deltafile=e:\wim\deltalist.txt"
    if exist %wimfile% del /s /q %wimfile% >nul
    if exist %deltafile% del /s /q %deltafile% >nul
    :: get WIM names from Folder
    for /r "e:\wim" %%a in (*.wim) do echo %%~na>>%wimfile%
    :: compare files and write difference to %deltafile%
    for /f "tokens=1 delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %textfile%) -DifferenceObject (Get-Content %wimfile%) ^| Format-Table -AutoSize" ^| findstr /i "=^>"') do echo %%a>>%deltafile%
    if not exist %deltafile% (
    echo No files to process found.
    echo:
    pause
    if exist %wimfile% del /s /q %wimfile% >nul
    exit
    )
    
    :: Path to files copy
    set path1=e:\files
    set target=e:\mount
    
    :: start procedure
    :: backup all WIMs to e:\backup\backup.wim
    echo.
    echo ===============================================================================
    echo Backing up to e:\backup\backup_%timestamp%.wim
    echo ===============================================================================
    echo.
    set "p=0"
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Exporting %%a to e:\backup\backup.wim
    echo.
    Dism /Export-Image /SourceImageFile:e:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:e:\backup\backup_%timestamp%.wim /compress:max /CheckIntegrity
    )
    :: mount single WIMs to e:\mount, add updates and unmount/commit
    echo.
    echo ===============================================================================
    echo Mounting to e:\mount
    echo Adding Updates
    echo Unmount/Commit
    echo ===============================================================================
    echo.
    :: execute loop for deltas only
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Processing %%a
    echo.
    DISM /mount-wim /wimfile:e:\wim\%%a.wim /index:1 /mountdir:e:\mount
    echo %%a | find "w7sp1x64" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates1%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates1%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates1%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates1%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates1%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates1%\Extra" %%a in (*.*) do set /a f+=1
    if /i %a% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Baseline
    if /i %b% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\General
    if /i %c% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Hotfix
    if /i %d% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Security
    if /i %e% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Additional
    if /i %f% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Extra
    )
    echo %%a | find "w7sp1x86" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates2%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates2%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates2%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates2%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates2%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates2%\Extra" %%a in (*.*) do set /a f+=1
    if /i %a% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Baseline
    if /i %b% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\General
    if /i %c% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Hotfix
    if /i %d% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Security
    if /i %e% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Additional
    if /i %f% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Extra
    )
    echo %%a | find "w8x64" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates3%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates3%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates3%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates3%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates3%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates3%\Extra" %%a in (*.*) do set /a f+=1
    if /i %a% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Baseline
    if /i %b% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\General
    if /i %c% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Hotfix
    if /i %d% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Security
    if /i %e% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Additional
    if /i %f% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Extra
    )
    echo %%a | find "w8x86" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates4%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates4%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates4%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates4%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates4%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates4%\Extra" %%a in (*.*) do set /a f+=1
    if /i %a% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Baseline
    if /i %b% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\General
    if /i %c% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Hotfix
    if /i %d% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Security
    if /i %e% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Additional
    if /i %f% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Extra
    )
    echo %%a | find "w81u1x64" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates5%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates5%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates5%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates5%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates5%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates5%\Extra" %%a in (*.*) do set /a f+=1
    if /i %a% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Baseline
    if /i %b% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\General
    if /i %c% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Hotfix
    if /i %d% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Security
    if /i %e% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Additional
    if /i %f% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Extra
    )
    echo %%a | find "w81u1x86" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates6%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates6%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates6%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates6%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates6%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates6%\Extra" %%a in (*.*) do set /a f+=1
    if /i %a% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Baseline
    if /i %b% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\General
    if /i %c% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Hotfix
    if /i %d% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Security
    if /i %e% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Additional
    if /i %f% gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Extra
    )
    xcopy.exe %path1%\*.* %target%\*.* /s /d /e /h /r /y
    DISM /unmount-wim /mountdir:e:\mount /commit
    echo %%a>>%textfile%
    )
    :: merge single WIMs to e:\master\install.wim
    echo.
    echo ===============================================================================
    echo Exporting to e:\master
    echo ===============================================================================
    echo.
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Exporting %%a to e:\master\install.wim
    echo.
    Dism /Export-Image /SourceImageFile:e:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:e:\master\install.wim /compress:max /CheckIntegrity
    )
    if exist %wimfile% del /s /q %wimfile% >nul
    if exist %deltafile% del /s /q %deltafile% >nul
    
    :: split master WIM
    echo.
    echo ===============================================================================
    echo Splitting WIM to e:\sources
    echo ===============================================================================
    echo.
    Dism /Split-Image /ImageFile:e:\master\install.wim /SWMFile:e:\sources\install.swm /FileSize:256
    
    :: end procedure
    :: script will pause here
    echo.
    echo ===============================================================================
    echo DONE ...
    echo ===============================================================================
    echo.
    pause
    
    :: EXIT
    endlocal
    exit
    

    Uses:

    Code:
    echo %%a | find "w81u1x64" 1>nul && (
    code to be processed when found the string here
    )
    to find the version string in the WIM name and process the updates for each defined version.



    ============================
    EDIT: Corrected wrong naming in set updates folder!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    It quickly errors out.
     
  14. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Need to check deeply after a nap ... checking out for now. Did you use edited version?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    #95 hypedave, Nov 20, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Yes sir I did, catch ya tomorrow. I found the culprit.

    Code:
    DISM   DISM.EXE: Executing command line: Dism  /Export-Image /SourceImageFile:e:\wim\At.wim /SourceIndex:1 /DestinationImageFile:e:\backup\backup_11-20-2014-00-36.wim /compress:max /CheckIntegrity
    
     
  16. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #96 s1ave77, Nov 20, 2014
    Last edited by a moderator: Apr 20, 2017
    Found the error, when setting a variable value inside a loop variable command must be !a! not %a% :doh:.

    Code:
    @echo off
    :: get admin rights
    (NET FILE||(powershell -command Start-Process '%0' -Verb runAs -ArgumentList '%* '&EXIT /B))>NUL 2>&1
    setLocal EnableDelayedExpansion
    
    :: Get timestamp data: will show month.day.year.hour.min.sec
    for /f "skip=1 delims=" %%x in ('wmic os get localdatetime') do if not defined X set X=%%x
    :: Timestamp with seconds
    :: set timestamp=%X:~4,2%-%X:~6,2%-%X:~0,4%-%X:~8,2%-%X:~10,2%-%X:~12,2%
    :: Timestamp without seconds
    set timestamp=%X:~4,2%-%X:~6,2%-%X:~0,4%-%X:~8,2%-%X:~10,2%
    :: Exclude WIms from 
    set textfile=e:\wim\exclusions.txt
    :: Path to update packages group 1
    set updates1=E:\updates\Windows7-x64
    :: Path to update packages group 2
    set updates2=E:\updates\Windows7-x86
    :: Path to update packages group 3
    set updates3=E:\updates\Windows8-x64
    :: Path to update packages group 4
    set updates4=E:\updates\Windows8-x86
    :: Path to update packages group 5
    set updates5=E:\updates\Windows8.1-x64
    :: Path to update packages group 6
    set updates6=E:\updates\Windows8.1-x86
    :: set compare files
    set "wimfile=e:\wim\wimlist.txt"
    set "deltafile=e:\wim\deltalist.txt"
    if exist %wimfile% del /s /q %wimfile% >nul
    if exist %deltafile% del /s /q %deltafile% >nul
    :: get WIM names from Folder
    for /r "e:\wim" %%a in (*.wim) do echo %%~na>>%wimfile%
    :: compare files and write difference to %deltafile%
    for /f "tokens=1 delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %textfile%) -DifferenceObject (Get-Content %wimfile%) ^| Format-Table -AutoSize" ^| findstr /i "= ^>"') do echo %%a>>%deltafile%
    if not exist %deltafile% (
    echo No files to process found.
    echo:
    pause
    if exist %wimfile% del /s /q %wimfile% >nul
    exit
    )
    
    :: Path to files copy
    set path1=e:\files
    set target=e:\mount
    
    :: start procedure
    :: backup all WIMs to e:\backup\backup.wim
    echo.
    echo ===============================================================================
    echo Backing up to e:\backup\backup_%timestamp%.wim
    echo ===============================================================================
    echo.
    set "p=0"
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Exporting %%a to e:\backup\backup.wim
    echo.
    Dism /Export-Image /SourceImageFile:e:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:e:\backup\backup_%timestamp%.wim /compress:max /CheckIntegrity
    )
    :: mount single WIMs to e:\mount, add updates and unmount/commit
    echo.
    echo ===============================================================================
    echo Mounting to e:\mount
    echo Adding Updates
    echo Unmount/Commit
    echo ===============================================================================
    echo.
    :: execute loop for deltas only
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Processing %%a
    echo.
    DISM /mount-wim /wimfile:e:\wim\%%a.wim /index:1 /mountdir:e:\mount
    echo %%a | find "w7sp1x64" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates1%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates1%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates1%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates1%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates1%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates1%\Extra" %%a in (*.*) do set /a f+=1
    if /i !a! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Baseline
    if /i !b! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\General
    if /i !c! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Hotfix
    if /i !d! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Security
    if /i !e! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Additional
    if /i !f! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates1%\Extra
    )
    echo %%a | find "w7sp1x86" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates2%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates2%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates2%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates2%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates2%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates2%\Extra" %%a in (*.*) do set /a f+=1
    if /i !a! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Baseline
    if /i !b! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\General
    if /i !c! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Hotfix
    if /i !d! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Security
    if /i !e! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Additional
    if /i !f! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates2%\Extra
    )
    echo %%a | find "w8x64" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates3%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates3%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates3%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates3%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates3%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates3%\Extra" %%a in (*.*) do set /a f+=1
    if /i !a! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Baseline
    if /i !b! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\General
    if /i !c! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Hotfix
    if /i !d! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Security
    if /i !e! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Additional
    if /i !f! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates3%\Extra
    )
    echo %%a | find "w8x86" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates4%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates4%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates4%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates4%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates4%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates4%\Extra" %%a in (*.*) do set /a f+=1
    if /i !a! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Baseline
    if /i !b! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\General
    if /i !c! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Hotfix
    if /i !d! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Security
    if /i !e! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Additional
    if /i !f! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates4%\Extra
    )
    echo %%a | find "w81u1x64" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates5%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates5%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates5%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates5%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates5%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates5%\Extra" %%a in (*.*) do set /a f+=1
    if /i !a! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Baseline
    if /i !b! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\General
    if /i !c! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Hotfix
    if /i !d! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Security
    if /i !e! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Additional
    if /i !f! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates5%\Extra
    )
    echo %%a | find "w81u1x86" 1>nul && (
    set "a=0"&&set "b=0"&&set "c=0"&&set "d=0"&&set "e=0"&&set "f=0"
    for /r "%updates6%\Baseline" %%a in (*.*) do set /a a+=1
    for /r "%updates6%\General%" %%a in (*.*) do set /a b+=1
    for /r "%updates6%\Hotfix" %%a in (*.*) do set /a c+=1
    for /r "%updates6%\Security" %%a in (*.*) do set /a d+=1
    for /r "%updates6%\Additional" %%a in (*.*) do set /a e+=1
    for /r "%updates6%\Extra" %%a in (*.*) do set /a f+=1
    if /i !a! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Baseline
    if /i !b! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\General
    if /i !c! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Hotfix
    if /i !d! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Security
    if /i !e! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Additional
    if /i !f! gtr 0 DISM /image:e:\mount /Add-Package /PackagePath:%updates6%\Extra
    )
    xcopy.exe %path1%\*.* %target%\*.* /s /d /e /h /r /y
    DISM /unmount-wim /mountdir:e:\mount /commit
    echo %%a>>%textfile%
    )
    :: merge single WIMs to e:\master\install.wim
    echo.
    echo ===============================================================================
    echo Exporting to e:\master
    echo ===============================================================================
    echo.
    for /f "tokens=* delims= " %%a in (%deltafile%) do (
    echo Exporting %%a to e:\master\install.wim
    echo.
    Dism /Export-Image /SourceImageFile:e:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:e:\master\install.wim /compress:max /CheckIntegrity
    )
    if exist %wimfile% del /s /q %wimfile% >nul
    if exist %deltafile% del /s /q %deltafile% >nul
    
    :: split master WIM
    echo.
    echo ===============================================================================
    echo Splitting WIM to e:\sources
    echo ===============================================================================
    echo.
    Dism /Split-Image /ImageFile:e:\master\install.wim /SWMFile:e:\sources\install.swm /FileSize:256
    
    :: end procedure
    :: script will pause here
    echo.
    echo ===============================================================================
    echo DONE ...
    echo ===============================================================================
    echo.
    pause
    
    :: EXIT
    endlocal
    exit
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    #97 hypedave, Nov 20, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Corrected code to use !a!. Still at original issue Dism can't create the backup.wim file

    Here is the DISM log. Go get some rest.

    Code:
    DISM   DISM.EXE: Executing command line: Dism  /Export-Image /SourceImageFile:e:\wim\At.wim /SourceIndex:1 /DestinationImageFile:e:\backup\backup_11-20-2014-00-45.wim /compress:max /CheckIntegrity
    
     
  18. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    Stupid mount folder is not clearing the copied files when dismounting or scripts is copying files to early to mount folder, arrgghhhhh!
    After clearing the files in the mount folder it's running now. Im going to bed to.
     
  19. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    ready when you are
     
  20. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Ready for what exactly ... :g:?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...