Here is the current code. Mysteriously and two new runs the files copied over to the mounted folder are now being removed when the imaged is saved and unmounted. Spoiler 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=d:\wim\exclusions.txt :: Path to update packages group 1 set updates1=d:\updates\Windows7-x64 :: Path to update packages group 2 set updates2=d:\updates\Windows7-x86 :: Path to update packages group 3 set updates3=d:\updates\Windows8-x64 :: Path to update packages group 4 set updates4=d:\updates\Windows8-x86 :: Path to update packages group 5 set updates5=d:\updates\Windows8.1-x64 :: Path to update packages group 6 set updates6=d:\updates\Windows8.1-x86 :: Path to Windows 7 x64 Make & Model Driver Store set drivers1=d:\drivers\Windows 7 x64 :: Path to Windows 8 x64 Make & Model Driver Store set drivers2=d:\drivers\Windows 8 x64 :: Path to Windows 8 x86 Make & Model Driver Store set drivers3=d:\drivers\Windows 8 x86 :: Path to Windows 8.1 x64 Make & Model Driver Store set drivers4=d:\drivers\Windows 8.1 x64 :: Path to Windows 8.1 x86 Make & Model Driver Store set drivers5=d:\drivers\Windows 8.1 x86 :: set compare files set "wimfile=d:\wim\wimlist.txt" set "deltafile=d:\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 "d:\wim" %%a in (*.wim) do echo %%~na>>%wimfile% :: compare files and write difference to %deltafile% for /f "tokens=* delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %textfile%) -DifferenceObject (Get-Content %wimfile%) ^| where-object SideIndicator -eq =^> ^| select -Expand InputObject ^| fl"') 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=d:\files set target=d:\mount :: start procedure :: backup all WIMs to d:\backup\backup.wim echo. echo =============================================================================== echo Backing up to d:\backup\backup_%timestamp%.wim echo =============================================================================== echo. set "p=0" for /f "tokens=* delims= " %%a in (%deltafile%) do ( echo Exporting %%a to d:\backup\backup.wim echo. Dism /Export-Image /SourceImageFile:d:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:d:\backup\backup_%timestamp%.wim /compress:max /CheckIntegrity ) :: mount single WIMs to d:\mount, add updates and unmount/commit echo. echo =============================================================================== echo Mounting to d:\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:d:\wim\%%a.wim /index:1 /mountdir:d:\mount echo %%a | find "w81u1x64_Lenovo_ThinkPad_Yoga" 1>nul && Dism /Image:D:\mount /Add-Driver /Driver:"%drivers4%\Lenovo\Thinkpad Yoga" /Recurse /ForceUnsigned xcopy.exe %path1%\*.* %target%\*.* /s /d /e /h /r /k /y 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:d:\mount /Add-Package /PackagePath:%updates1%\Baseline if /i !b! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates1%\General if /i !c! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates1%\Hotfix if /i !d! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates1%\Security if /i !e! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates1%\Additional if /i !f! gtr 0 DISM /image:d:\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:d:\mount /Add-Package /PackagePath:%updates2%\Baseline if /i !b! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates2%\General if /i !c! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates2%\Hotfix if /i !d! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates2%\Security if /i !e! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates2%\Additional if /i !f! gtr 0 DISM /image:d:\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:d:\mount /Add-Package /PackagePath:%updates3%\Baseline if /i !b! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates3%\General if /i !c! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates3%\Hotfix if /i !d! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates3%\Security if /i !e! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates3%\Additional if /i !f! gtr 0 DISM /image:d:\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:d:\mount /Add-Package /PackagePath:%updates4%\Baseline if /i !b! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates4%\General if /i !c! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates4%\Hotfix if /i !d! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates4%\Security if /i !e! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates4%\Additional if /i !f! gtr 0 DISM /image:d:\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:d:\mount /Add-Package /PackagePath:%updates5%\Baseline if /i !b! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates5%\General if /i !c! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates5%\Hotfix if /i !d! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates5%\Security if /i !e! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates5%\Additional if /i !f! gtr 0 DISM /image:d:\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:d:\mount /Add-Package /PackagePath:%updates6%\Baseline if /i !b! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates6%\General if /i !c! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates6%\Hotfix if /i !d! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates6%\Security if /i !e! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates6%\Additional if /i !f! gtr 0 DISM /image:d:\mount /Add-Package /PackagePath:%updates6%\Extra ) DISM /unmount-wim /mountdir:d:\mount /commit echo %%a>>%textfile% ) :: merge single WIMs to d:\master\install.wim echo. echo =============================================================================== echo Exporting to d:\master echo =============================================================================== echo. for /f "tokens=* delims= " %%a in (%deltafile%) do ( echo Exporting %%a to d:\master\install.wim echo. Dism /Export-Image /SourceImageFile:d:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:d:\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 d:\sources echo =============================================================================== echo. Dism /Split-Image /ImageFile:d:\master\install.wim /SWMFile:d:\sources\install.swm /FileSize:256 :: end procedure :: script will pause here echo. echo =============================================================================== echo DONE ... echo =============================================================================== echo. pause :: EXIT endlocal exit /CODE][/SPOILER]
If the compare error persists, make sure the TXT files are written correctly. Compare here only fails when a file isn't properly created or non-existent. '[' is missing at end of code tags.
Ok so if i understand you correctly, the following text files need to be present D:\wim\exclusions.txt D:\wim\deltalist.txt D:\wim\wimlist.txt Is wimlist.txt supposed to be removed? Code: [:: set compare files set "wimfile=d:\wim\wimlist.txt" set "deltafile=d:\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 "d:\wim" %%a in (*.wim) do echo %%~na>>%wimfile% :: compare files and write difference to %deltafile% for /f "tokens=* delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %textfile%) -DifferenceObject (Get-Content %wimfile%) ^| where-object SideIndicator -eq =^> ^| select -Expand InputObject ^| fl"') 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 ) Now here is another bone to throw at you. The new drivers were added, however the image to still hanging on to the old driver. Some kinda way need to figure out how to remove the old drivers using the dism command before adding the new driver. The command would be Code: [Dism /Image:D:\mount /Remove-Driver /Driver:OEM1.inf /Driver:OEM2.inf/CODE] But issue I see is possibly having to create a text file with any driver inf file that needs to be removed based on again the title of the wim file. Based on how we are using the set command here is what im coming up. Code: :: Path to textfile with Drivers to remove set Remove-Driver=d:\drivers\remove-drivers.txt Now how to call it to the text file and properly setup the text file is where im lost at. Will powershell compare-object be required? If that's true then the following text ar
wimlist.txt is deleted at beginning to assure writing to an empty file (can't use '>' in a for-loop as it would result in a single line in the file). Then get's deleted when no files to process are found, before it exits. Else it must be there for the WIM maintenance processes.
So technically the only file that needs to exist is E:\wim\exclusionslist.txt The other two files are created automatically then deleted.
Ok thanks, im struggling over the removal of drivers now. May have to user a different alternative to tackle this one.
Ok so here are my last three challenges Use dism to query for updates already installed. Only install updates missing. Use dism to remove drivers based on reading a text file for make and model.
Query mounted WIM for already integrated updates and write to TXT file . Code: for /f "tokens=5,6,7 delims=:_~ " %%a in ('"dism /online /Get-Packages /english" ^| findstr /i Package') do if not %%a equ amd64 if not %%a equ x86 echo %%a&&echo %%a>>d:\wim\integrated.txt
From what I can tell is I think *knock on wood* it worked. Would it best to also have this as a autodeleting file prior to each wim being mounted?
Well my RAID controller card died on me, just bought the freaking thing too. Redoing my computer. I'll have to read all over this thread again to put a new working script file together. Lost 12tb of data and it's taking Ubuntu forever to recover any data.
Ohh ... my condolence then, for your lost. Leave a sign when you're ready to proceed . Still have the code i copied last from you, only lacks the add drivers part.
Ok i'm back and ready to proceed. The driver part is going to require to work. It injects the new driver as expected. Problem is that if the new driver is replacing an older driver then the older driver still remains until to manually uninstall the old driver and then the OS will choose the new driver. So here is the code I was able to retrieve. Spoiler 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=f:\images\exclusions.txt :: Path to update packages group 1 set updates1=f:\updates\Windows7-x64 :: Path to update packages group 2 set updates2=f:\updates\Windows7-x86 :: Path to update packages group 3 set updates3=f:\updates\Windows8-x64 :: Path to update packages group 4 set updates4=f:\updates\Windows8-x86 :: Path to update packages group 5 set updates5=f:\updates\Windows8.1-x64 :: Path to update packages group 6 set updates6=f:\updates\Windows8.1-x86 :: Path to Windows 7 x64 Make & Model Driver Store set drivers1=f:\drivers\Windows 7 x64 :: Path to Windows 8 x64 Make & Model Driver Store set drivers2=f:\drivers\Windows 8 x64 :: Path to Windows 8 x86 Make & Model Driver Store set drivers3=f:\drivers\Windows 8 x86 :: Path to Windows 8.1 x64 Make & Model Driver Store set drivers4=f:\drivers\Windows 8.1 x64 :: Path to Windows 8.1 x86 Make & Model Driver Store set drivers5=f:\drivers\Windows 8.1 x86 :: set compare files set "wimfile=f:\images\wimlist.txt" set "deltafile=f:\images\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 "f:\images" %%a in (*.wim) do echo %%~na>>%wimfile% :: compare files and write difference to %deltafile% for /f "tokens=* delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %textfile%) -DifferenceObject (Get-Content %wimfile%) ^| where-object SideIndicator -eq =^> ^| select -Expand InputObject ^| fl"') 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=f:\files set target=f:\mount :: start procedure :: backup all WIMs to f:\backup\backup.wim echo. echo =============================================================================== echo Backing up to f:\backup\backup_%timestamp%.wim echo =============================================================================== echo. set "p=0" for /f "tokens=* delims= " %%a in (%deltafile%) do ( echo Exporting %%a to f:\backup\backup.wim echo. Dism /Export-Image /SourceImageFile:f:\images\%%a.wim /SourceIndex:1 /DestinationImageFile:f:\backup\backup_%timestamp%.wim /compress:max /CheckIntegrity ) :: mount single WIMs to f:\mount, add updates and unmount/commit echo. echo =============================================================================== echo Mounting to f:\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:f:\images\%%a.wim /index:1 /mountdir:f:\mount echo %%a | find "w81u1x64_Lenovo_ThinkPad_Yoga" 1>nul && Dism /Image:f:\mount /Add-Driver /Driver:"%drivers4%\Lenovo\Thinkpad Yoga" /Recurse /ForceUnsigned powershell.exe remove-item "%target%\Users\Public\Desktop\Encore Login.url" -force powershell.exe remove-item %target%\lanrev* -recurse -force powershell.exe remove-item "%target%\programdata\pole position software\lanrev agent\cacheddata\*.*" -recurse -force xcopy.exe %path1%\*.* %target%\*.* /s /d /e /h /r /k /y for /f "tokens=5,6,7 delims=:_~ " %%a in ('"dism /online /Get-Packages /english" ^| findstr /i Package') do if not %%a equ amd64 if not %%a equ x86 echo %%a&&echo %%a>>f:\images\integrated.txt 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:f:\mount /Add-Package /PackagePath:%updates1%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates1%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates1%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates1%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates1%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates2%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates2%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates2%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates2%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates2%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates3%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates3%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates3%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates3%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates3%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates4%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates4%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates4%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates4%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates4%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates5%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates5%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates5%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates5%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates5%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates6%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\Additional if /i !f! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\Extra ) DISM /unmount-wim /mountdir:f:\mount /commit echo %%a>>%textfile% ) :: merge single WIMs to f:\master\install.wim echo. echo =============================================================================== echo Exporting to f:\master echo =============================================================================== echo. for /f "tokens=* delims= " %%a in (%deltafile%) do ( echo Exporting %%a to f:\master\install.wim echo. Dism /Export-Image /SourceImageFile:f:\images\%%a.wim /SourceIndex:1 /DestinationImageFile:f:\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 f:\sources echo =============================================================================== echo. Dism /Split-Image /ImageFile:f:\master\install.wim /SWMFile:f:\sources\install.swm /FileSize:512 :: end procedure :: script will pause here echo. echo =============================================================================== echo DONE ... echo =============================================================================== echo. pause :: EXIT endlocal exit/CODE][/SPOILER] Is it possible to add a menu to this? Doing a test run now on a WIM that has the most most updates and checking to see if the script see's the updates and won't try to install them.
My last version: 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=f:\wim\exclusions.txt :: Path to update packages group 1 set updates1=f:\updates\Windows7-x64 :: Path to update packages group 2 set updates2=f:\updates\Windows7-x86 :: Path to update packages group 3 set updates3=f:\updates\Windows8-x64 :: Path to update packages group 4 set updates4=f:\updates\Windows8-x86 :: Path to update packages group 5 set updates5=f:\updates\Windows8.1-x64 :: Path to update packages group 6 set updates6=f:\updates\Windows8.1-x86 :: set compare files set "wimfile=f:\wim\wimlist.txt" set "deltafile=f:\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 "f:\wim" %%a in (*.wim) do echo %%~na>>%wimfile% :: compare files and write difference to %deltafile% for /f "tokens=* delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %textfile%) -DifferenceObject (Get-Content %wimfile%) ^| where-object SideIndicator -eq =^> ^| select -Expand InputObject ^| fl"') 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=f:\files set target=f:\mount :: start procedure :: backup all WIMs to f:\backup\backup.wim echo. echo =============================================================================== echo Backing up to f:\backup\backup_%timestamp%.wim echo =============================================================================== echo. set "p=0" for /f "tokens=* delims= " %%a in (%deltafile%) do ( echo Exporting %%a to f:\backup\backup.wim echo. Dism /Export-Image /SourceImageFile:f:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:f:\backup\backup_%timestamp%.wim /compress:max /CheckIntegrity ) :: mount single WIMs to f:\mount, add updates and unmount/commit echo. echo =============================================================================== echo Mounting to f:\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:f:\wim\%%a.wim /index:1 /mountdir:f:\mount echo %%a | find "w81u1x64_Lenovo_ThinkPad_Yoga" 1>nul && Dism /Image:f:\mount /Add-Driver /Driver:"%drivers4%\Lenovo\Thinkpad Yoga" /Recurse /ForceUnsigned powershell.exe remove-item "%target%\Users\Public\Desktop\Encore Login.url" -force powershell.exe remove-item %target%\lanrev* -recurse -force powershell.exe remove-item "%target%\programdata\pole position software\lanrev agent\cacheddata\*.*" -recurse -force xcopy.exe %path1%\*.* %target%\*.* /s /d /e /h /r /k /y for /f "tokens=5,6,7 delims=:_~ " %%a in ('"dism /online /Get-Packages /english" ^| findstr /i Package') do if not %%a equ amd64 if not %%a equ x86 echo %%a&&echo %%a>>f:\images\integrated.txt 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:f:\mount /Add-Package /PackagePath:%updates1%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates1%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates1%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates1%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates1%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates2%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates2%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates2%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates2%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates2%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates3%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates3%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates3%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates3%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates3%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates4%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates4%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates4%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates4%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates4%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates5%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates5%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates5%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates5%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates5%\Additional if /i !f! gtr 0 DISM /image:f:\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:f:\mount /Add-Package /PackagePath:%updates6%\Baseline if /i !b! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\General if /i !c! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\Hotfix if /i !d! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\Security if /i !e! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\Additional if /i !f! gtr 0 DISM /image:f:\mount /Add-Package /PackagePath:%updates6%\Extra ) set "driversw7x64=E:\drivers\Windows 7 x64" echo %%a | find "w7sp1x64_Dell_Latitude_3340" 1>nul && Dism /Image:"F:\mount" /Add-Driver /Driver:"%driversw7x64%\Dell\Latitude 3340" /Recurse /ForceUnsigned xcopy.exe %path1%\*.* %target%\*.* /s /d /e /h /r /k /y DISM /unmount-wim /mountdir:f:\mount /commit echo %%a>>%textfile% ) :: merge single WIMs to f:\master\install.wim echo. echo =============================================================================== echo Exporting to f:\master echo =============================================================================== echo. for /f "tokens=* delims= " %%a in (%deltafile%) do ( echo Exporting %%a to f:\master\install.wim echo. Dism /Export-Image /SourceImageFile:f:\wim\%%a.wim /SourceIndex:1 /DestinationImageFile:f:\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 f:\sources echo =============================================================================== echo. Dism /Split-Image /ImageFile:f:\master\install.wim /SWMFile:f:\sources\install.swm /FileSize:256 :: end procedure :: script will pause here echo. echo =============================================================================== echo DONE ... echo =============================================================================== echo. pause :: EXIT endlocal exit Menu is no problem.
Thanks, im assuming this is the version with out the drivers? I may have found a work around for the part. I'll just have to use DISM to manually remove whatever driver needs to be removed, no big deal there. Code: Dism /Image:f:\mount /Remove-Driver /Driver:OEM1.inf /Driver:OEM2.inf