Correct, updates are still being installed offline even though they are already installed when the image was captured.
Yeah, so far normal, as it only writes the installed updates to TXT file but needs to compare with Update folders and then only install the missing. Similiar compare like the one for exclusion list but with integrated.txt and foldercontent.txt >> integrate.txt, then install by filtering the folder aginst the file to get the update pathes correctly.
Oh ok well here is what else I have observed to. Image A is mounted Mounted image is scanned for installed updates Updates are log to integrated.txt file Script continues to run Image is unmounted The next image that is mounted logs in current updates to integrated.txt and now there are double entries from the previous mounted wim.
Also normal behavior. In a for-loop you need to use '>>' as '>' would repeatedly overwrite the line, so you need to delete the file when you re-do the process .
While working on another script i realized that your script could be optimized by using calls to avoid the nearly redundant parts in update integration. Need to check that next. Today i'm a bit braindead due to working on several projects intensively the last days .
Oh ok well cool beans, you've been very helpful just let me know when you ready. I was just playing around with something; Code: set "packages=f:\images\packages.txt" if exist %packages% del /s /q %packages% >nul 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\%packages%
Couldn't let it go, stick was to seductive it seems . 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 ::=============================================================================================================== :: 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" set "packages=f:\images\packages.txt" set "folderpackages=f:\images\folderpackages.txt" set "integratepackages=f:\images\integratepackages.txt" if exist %wimfile% del /s /q %wimfile% >nul if exist %deltafile% del /s /q %deltafile% >nul ::=============================================================================================================== :: GET WIM NAMES FROM FOLDER call :CheckFolder f:\wim, %wimfile% :: compare files and write difference to %deltafile% ::=============================================================================================================== call :CompareWithPowershell %textfile%, %wimfile%, %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. ::=============================================================================================================== ::MOUNT DISM /mount-wim /wimfile:f:\wim\%%a.wim /index:1 /mountdir:f:\mount ::=============================================================================================================== ::ADD DRIVERS 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 ::=============================================================================================================== ::ADD UPDATES echo %%a | find "w7sp1x64" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates1%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates1%, f:\mount ) echo %%a | find "w7sp1x86" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates2%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates2%, f:\mount ) echo %%a | find "w8x64" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates3%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates3%, f:\mount ) echo %%a | find "w8x86" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates4%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates4%, f:\mount ) echo %%a | find "w81u1x64" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates5%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates5%, f:\mount ) echo %%a | find "w81u1x86" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates6%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates6%, f:\mount ) ::=============================================================================================================== ::UNMOUNT 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 :================================================================================================================ ::=============================================================================================================== ::COMPARE LISTS WITH POWERSHELL :CompareWithPowershell for /f "tokens=* delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %~1) -DifferenceObject (Get-Content %~2) ^| where-object SideIndicator -eq =^> ^| select -Expand InputObject ^| fl"') do echo %%a>>%~3 goto:eof ::=============================================================================================================== ::CHECK FOLDER :CheckFolder for /r "%~1" %%a in (*.wim) do echo %%~na>>%~2 goto:eof ::=============================================================================================================== ::CHECK WIM :CheckMountedWIM if exist %wimfile% del /s /q %wimfile% >nul 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>>%~1 goto:eof ::=============================================================================================================== ::INTEGRATE PACKAGES :IntegratePackages for /f "tokens=* delims= " %%a in (%~1) do ( for /r "%~2" %%i in (*.wim) do ( echo %%~ni | findstr /i "%%a" 1>nul && DISM /image:%~3 /Add-Package /PackagePath:%%i )) if exist %packages% del /s /q %packages% >nul if exist %folderpackages% del /s /q %folderpackages% >nul if exist %integratepackages% del /s /q %integratepackages% >nul goto:eof Now uses calls. Added some REM lines for better readability.
Cool beans, much cleaner too. I took out Code: [::=============================================================================================================== :: Path to update packages group 6 set updates6=f:\updates\Windows8.1-x86 It was in there twice. Let me run this real quick.
Interestingly it performs less folder checks that way, as it now scans the main updates folder for each system/arch once, creates a delta list and integrates updates on that list only .
Well its not attempting to inject updates. check out the error before it mounts the wim Code: =============================================================================== Backing up to f:\backup\backup_12-01-2014-03-04.wim ===============================================================================Exporting testwim_11-01-2014 to f:\backup\backup.wim Deployment Image Servicing and Management tool Version: 6.3.9600.17031 Exporting image [==========================100.0%==========================] The operation completed successfully. =============================================================================== Mounting to f:\mount Adding Updates Unmount/Commit =============================================================================== Processing testwim_11-01-2014 The system cannot find the drive specified. Deployment Image Servicing and Management tool Version: 6.3.9600.17031 Mounting image [===========================52.0% My guess is this guy right here Code: ::=============================================================================================================== ::EXECUTE LOOP FOR DELTAS ONLY for /f "tokens=* delims= " %%a in (%deltafile%) do ( echo Processing %%a echo. ::=============================================================================================================== ::MOUNT DISM /mount-wim /wimfile:f:\images\%%a.wim /index:1 /mountdir:f:\mount ::===============================================================================================================
Nope, it's shown correctly. You need to define the variable for the drivers: %drivers4%\Lenovo\Thinkpad Yoga Then try again. BTW: Just realised you used 'testwim_11-01-2014' as name of the WIM. This contains neither Windows version string nor Manufacturer one, so the script will mount but can't add anything as that needs the mentioned strings to present in the name .
I did, here is the full code from top to bottom. The variable is set to %drivers5%. Now what's gonna happen when all the files are named differently and that variable is still there, hmmmm. (Also I renamed the wim due to privacy reasons in the example I gave you). 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 7 x86 :: Path to Windows 8 x64 Make & Model Driver Store set drivers3=f:\drivers\Windows 8 x64 :: Path to Windows 8 x86 Make & Model Driver Store set drivers4=f:\drivers\Windows 8 x86 :: Path to Windows 8.1 x64 Make & Model Driver Store set drivers5=f:\drivers\Windows 8.1 x64 :: Path to Windows 8.1 x86 Make & Model Driver Store set drivers6=f:\drivers\Windows 8.1 x86 ::=============================================================================================================== :: SET COMPARE FILES set "wimfile=f:\images\wimlist.txt" set "deltafile=f:\images\deltalist.txt" set "packages=f:\images\packages.txt" set "folderpackages=f:\images\folderpackages.txt" set "integratepackages=f:\images\integratepackages.txt" if exist %wimfile% del /s /q %wimfile% >nul if exist %deltafile% del /s /q %deltafile% >nul ::=============================================================================================================== :: GET WIM NAMES FROM FOLDER call :CheckFolder f:\images, %wimfile% :: compare files and write difference to %deltafile% ::=============================================================================================================== call :CompareWithPowershell %textfile%, %wimfile%, %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. ::=============================================================================================================== ::MOUNT DISM /mount-wim /wimfile:f:\images\%%a.wim /index:1 /mountdir:f:\mount ::=============================================================================================================== ::ADD DRIVERS echo %%a | find "w81u1x64_Lenovo_ThinkPad_Yoga" 1>nul && Dism /Image:f:\mount /Add-Driver /Driver:"%drivers5%\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 ::=============================================================================================================== ::ADD UPDATES echo %%a | find "w7sp1x64" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates1%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates1%, f:\mount ) echo %%a | find "w7sp1x86" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates2%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates2%, f:\mount ) echo %%a | find "w8x64" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates3%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates3%, f:\mount ) echo %%a | find "w8x86" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates4%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates4%, f:\mount ) echo %%a | find "w81u1x64" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates5%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates5%, f:\mount ) echo %%a | find "w81u1x86" 1>nul && ( call :CheckMountedWIM %packages% call :CheckFolder %updates6%, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates6%, f:\mount ) ::=============================================================================================================== ::UNMOUNT 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 :================================================================================================================ ::=============================================================================================================== ::COMPARE LISTS WITH POWERSHELL :CompareWithPowershell for /f "tokens=* delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %~1) -DifferenceObject (Get-Content %~2) ^| where-object SideIndicator -eq =^> ^| select -Expand InputObject ^| fl"') do echo %%a>>%~3 goto:eof ::=============================================================================================================== ::CHECK FOLDER :CheckFolder for /r "%~1" %%a in (*.wim) do echo %%~na>>%~2 goto:eof ::=============================================================================================================== ::CHECK WIM :CheckMountedWIM if exist %wimfile% del /s /q %wimfile% >nul 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>>%~1 goto:eof ::=============================================================================================================== ::INTEGRATE PACKAGES :IntegratePackages for /f "tokens=* delims= " %%a in (%~1) do ( for /r "%~2" %%i in (*.wim) do ( echo %%~ni | findstr /i "%%a" 1>nul && DISM /image:%~3 /Add-Package /PackagePath:%%i )) if exist %packages% del /s /q %packages% >nul if exist %folderpackages% del /s /q %folderpackages% >nul if exist %integratepackages% del /s /q %integratepackages% >nul goto:eof Also this error is the first line in "exclusions.txt" Code: Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it is null. Also would it be possible to have the required txt created automatically before script execution. So many additional txt files now throwing off guard on which are really needed, lol.
here is a full output of the script ( I highlighted the errors in red) Spoiler Code: =============================================================================== Backing up to f:\backup\backup_12-01-2014-09-04.wim ===============================================================================Exporting TestProject_w81u1x64_Lenovo_ThinkPad_Helix_01-01-2014 to f:\backup\backup.wim Deployment Image Servicing and Management tool Version: 6.3.9600.17031 Exporting image [==========================100.0%==========================] The operation completed successfully. =============================================================================== Mounting to f:\mount Adding Updates Unmount/Commit =============================================================================== Processing TestProject_w81u1x64_Lenovo_ThinkPad_Helix_01-01-2014 The system cannot find the drive specified. Deployment Image Servicing and Management tool Version: 6.3.9600.17031 Mounting image [==========================100.0%==========================] The operation completed successfully. The system cannot find the drive specified. Remove-Item : A positional parameter cannot be found that accepts argument 'Login.url'. At line:1 char:1 + remove-item f:\mount\Users\Public\Desktop\Encore Login.url -force + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Remove-Item], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand Remove-Item : A positional parameter cannot be found that accepts argument 'position'. At line:1 char:1 + remove-item f:\mount\programdata\pole position software\lanrev agent\cacheddata\ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Remove-Item], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand 0 File(s) copied The system cannot find the drive specified. The system cannot find the drive specified. Deployment Image Servicing and Management tool Version: 6.3.9600.17031 Image File : f:\images\TestProject_w81u1x64_Lenovo_ThinkPad_Helix_01-01-2014.wim Image Index : 1 Saving image [==========================100.0%==========================] Unmounting image [==========================100.0%==========================] The operation completed successfully. =============================================================================== Exporting to f:\master =============================================================================== Exporting TestProject_w81u1x64_Lenovo_ThinkPad_Helix_01-01-2014 to f:\master\install.wim Deployment Image Servicing and Management tool Version: 6.3.9600.17031 Exporting image [==========================100.0%==========================] The operation completed successfully. =============================================================================== Splitting WIM to f:\sources =============================================================================== Deployment Image Servicing and Management tool Version: 6.3.9600.17031 The operation completed successfully. =============================================================================== DONE ... =============================================================================== Press any key to continue . . . Guess now with this new script method I need to figure out a if then method to remove files and folders from the mounted image, arrghh.
Problem seems to be the Compare. Wrote this blind, so to say, need to create a test environment to check. Will report back .
What should i say ... found the time to create a little test environment and realised the errors, after short time . While using code from my WU TOOL i forgot to adapt it completely to the new challenge (i.e. checking folder for a) wim and then b) msu files needs to be defined for each situation ...). Will post a new excerpt soon :ggod3:. YEP, can confirm first success :flowers2:. Now it checks the mounted WIM for already integrated Updates, checks the updates folder and after a compare offers the Updates needed for integration and starts the integration progress for the WIM. I used one mounted WIM i pointed the test script to and for the second WIM for the script (but still the same mounted here) it recognizes the Updates in the folder are already integrated and moves on. Code: TestProject_w81u1x64_Lenovo_ThinkPad_Helix_02-01-2014 TestProject_w81u1x64_Lenovo_ThinkPad_Helix_04-01-2014 TestProject_w81u1x64_Lenovo_ThinkPad_Helix_05-01-2014 TestProject_w81u1x64_Lenovo_ThinkPad_Helix_06-01-2014 Drücken Sie eine beliebige Taste . . . =============================================================================== Mounting to f:\mount Adding Updates Unmount/Commit =============================================================================== Processing TestProject_w81u1x64_Lenovo_ThinkPad_Helix_02-01-2014 Gewartet wird 4 Sekunden. Weiter mit beliebiger Taste... KB2919355 KB2919442 KB2932046 KB2937220 KB2937592 KB2938439 KB2938772 KB2939471 KB2949621 Drücken Sie eine beliebige Taste . . . KB2968296 KB2972103 KB2977292 KB2978041 KB2979573 KB2979576 KB2987107 KB2989542 KB2989647 KB2995388 KB2998174 KB2998527 KB3000061 KB3000869 KB3000988 KB3001237 Drücken Sie eine beliebige Taste . . . KB2968296 KB2972103 KB2977292 KB2978041 KB2979573 KB2979576 KB2987107 KB2989542 KB2989647 KB2995388 KB2998174 KB2998527 KB3000061 KB3000869 KB3000988 KB3001237 Drücken Sie eine beliebige Taste . . . Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2968296-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2972103-v2-x64.ms u" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2977292-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2978041-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2979573-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2979576-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2987107-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2989542-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2989647-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2995388-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2998174-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB2998527-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB3000061-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB3000869-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB3000988-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Tool zur Imageverwaltung für die Bereitstellung Version: 6.3.9600.17031 Abbildversion: 6.3.9600.17031 1 von 1 werden verarbeitet - Paket "f:\win\update\Windows8.1-KB3001237-x64.msu" wird hinzugefügt [==========================100.0%==========================] Der Vorgang wurde erfolgreich beendet. Success.... Gewartet wird 0 Sekunden. Weiter mit beliebiger Taste... Processing TestProject_w81u1x64_Lenovo_ThinkPad_Helix_04-01-2014 Gewartet wird 0 Sekunden. Weiter mit beliebiger Taste... KB2919355 KB2919442 KB2932046 KB2937220 KB2937592 KB2938439 KB2938772 KB2939471 KB2949621 KB2968296 KB2972103 KB2977292 KB2978041 KB2979573 KB2979576 KB2987107 KB2989542 KB2989647 KB2995388 KB2998174 KB2998527 KB3000061 KB3000869 KB3000988 KB3001237 Drücken Sie eine beliebige Taste . . . KB2968296 KB2972103 KB2977292 KB2978041 KB2979573 KB2979576 KB2987107 KB2989542 KB2989647 KB2995388 KB2998174 KB2998527 KB3000061 KB3000869 KB3000988 KB3001237 Drücken Sie eine beliebige Taste . . . Das System kann die angegebene Datei nicht finden. Drücken Sie eine beliebige Taste . . .
IMAGE SERVICING TOOL v.0.20 OK in my test scenario it does was it's supposed to. Now it needs thorough checks with real files ... your turn . Changelog Added variables for WIM and Mount folder (allows to easier change the paths, else it would need to change all occurances) Added more variables for all pathes (i.e backup/master/source) Reworked the Folder Check processes Added "" for ALL pathes (it's always clever as you don't need to care about the pathes) Added List Cleanup for every run Credits added SCRIPT (better use the whole thingie): Code: @echo off title þ IMAGE SERVICING TOOL þ v.0.20 ::Idea/Motivation: hypedave, Code: s1ave77 (forums.mydigitallife.net) ::=============================================================================================================== :: 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 "mountfolder=f:\mount" set "wimfolder=f:\wim" set "backupfolder=f:\backup" set "masterfolder=f:\master" set "sourcefolder=f:\source" set "wimfile=f:\wim\wimlist.txt" set "deltafile=f:\wim\deltalist.txt" set "packages=f:\images\packages.txt" set "folderpackages=f:\images\folderpackages.txt" set "integratepackages=f:\images\integratepackages.txt" if exist %wimfile% del /s /q %wimfile% >nul if exist %deltafile% del /s /q %deltafile% >nul ::=============================================================================================================== :: GET WIM NAMES FROM FOLDER call :CheckFolder %wimfolder%, wim, %wimfile% :: compare files and write difference to %deltafile% ::=============================================================================================================== call :CompareWithPowershell %textfile%, %wimfile%, %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:"%wimfolder%\%%a.wim" /SourceIndex:1 /DestinationImageFile:"%backupfolder%\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:"%mountfolder%" 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 echo %%a | find "w7sp1x64" 1>nul && ( call :CheckMountedWIM %mountfolder%, %packages% call :CheckUpdateFolder %updates1%, msu, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates1%, msu, %mountfolder% if exist %packages% del /s /q %packages% >nul if exist %folderpackages% del /s /q %folderpackages% >nul ) echo %%a | find "w7sp1x86" 1>nul && ( call :CheckMountedWIM %mountfolder%, %packages% call :CheckUpdateFolder %updates2%, msu, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates2%, msu, %mountfolder% if exist %packages% del /s /q %packages% >nul if exist %folderpackages% del /s /q %folderpackages% >nul ) echo %%a | find "w8x64" 1>nul && ( call :CheckMountedWIM %mountfolder%, %packages% call :CheckUpdateFolder %updates3%, msu, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates3%, msu, %mountfolder% if exist %packages% del /s /q %packages% >nul if exist %folderpackages% del /s /q %folderpackages% >nul ) echo %%a | find "w8x86" 1>nul && ( call :CheckMountedWIM %mountfolder%, %packages% call :CheckUpdateFolder %updates4%, msu, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates4%, msu, %mountfolder% if exist %packages% del /s /q %packages% >nul if exist %folderpackages% del /s /q %folderpackages% >nul ) echo %%a | find "w81u1x64" 1>nul && ( call :CheckMountedWIM %mountfolder%, %packages% call :CheckUpdateFolder %updates5%, msu, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates5%, msu, %mountfolder% if exist %packages% del /s /q %packages% >nul if exist %folderpackages% del /s /q %folderpackages% >nul ) echo %%a | find "w81u1x86" 1>nul && ( call :CheckMountedWIM %mountfolder%, %packages% call :CheckUpdateFolder %updates6%, msu, %folderpackages% call :CompareWithPowershell %packages%, %folderpackages%, %integratepackages% if exist %integratepackages% call :IntegratePackages %integratepackages%, %updates6%, msu, %mountfolder% if exist %packages% del /s /q %packages% >nul if exist %folderpackages% del /s /q %folderpackages% >nul ) DISM /unmount-wim /mountdir:"%mountfolder%" /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:"%wimfolder%\%%a.wim" /SourceIndex:1 /DestinationImageFile:"%masterfolder%\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:"%masterfolder%\install.wim" /SWMFile:"%sourcefolder%\install.swm" /FileSize:256 :================================================================================================================ ::=============================================================================================================== :: END PROCEDURE :: script will pause here echo. echo =============================================================================== echo DONE ... echo =============================================================================== echo. pause :================================================================================================================ ::=============================================================================================================== :: EXIT endlocal exit :================================================================================================================ ::=============================================================================================================== ::COMPARE LISTS WITH POWERSHELL :CompareWithPowershell for /f "tokens=* delims= " %%a in ('"powershell Compare-Object -ReferenceObject (Get-Content %~1) -DifferenceObject (Get-Content %~2) ^| where-object SideIndicator -eq =^> ^| select -Expand InputObject ^| fl"') do echo %%a>>%~3 goto:eof ::=============================================================================================================== ::CHECK FOLDER :CheckFolder for /r "%~1" %%a in (*.%~2) do echo %%~na>>%~3 goto:eof ::=============================================================================================================== ::CHECK FOLDER II :CheckUpdateFolder for /r "%~1" %%i in (*.%~2) do ( set "updatetemp=%%~ni" for /f "tokens=2 delims=-" %%m in ("!updatetemp!") do echo %%m>>%~3 ) goto:eof ::=============================================================================================================== ::CHECK WIM :CheckMountedWIM if exist %wimfile% del /s /q %wimfile% >nul for /f "tokens=5,6,7 delims=:_~ " %%a in ('"dism /image:%~1 /Get-Packages /english" ^| findstr /i Package') do if not %%a equ amd64 if not %%a equ x86 echo %%a>>%~2 goto:eof ::=============================================================================================================== ::INTEGRATE PACKAGES :IntegratePackages for /f "tokens=* delims= " %%a in (%~1) do ( for /r "%~2" %%i in (*.%~3) do ( echo %%~ni | findstr /i "%%a" 1>nul && DISM /image:%~4 /Add-Package /PackagePath:%%i )) if exist %packages% del /s /q %packages% >nul if exist %folderpackages% del /s /q %folderpackages% >nul if exist %integratepackages% del /s /q %integratepackages% >nul goto:eof
Quick question Code: ::=============================================================================================================== :: SET COMPARE FILES set "mountfolder=f:\mount" set "wimfolder=f:\wim" set "wimfile=f:\wim\wimlist.txt" set "deltafile=f:\wim\deltalist.txt" set "packages=f:\images\packages.txt" set "folderpackages=f:\images\folderpackages.txt" set "integratepackages=f:\images\integratepackages.txt" if exist %wimfile% del /s /q %wimfile% >nul if exist %deltafile% del /s /q %deltafile% >nul ::=============================================================================================================== I am trying to keep the folder structure at a minimal. I no longer user a folder called WIM, it's been renamed to images. Can I move the packages.txt, folderpackages.txt and integratedpacked.txt to f:\updates?
Yep, your choice, for that reason i added all of them as variable, so you'll only need to change it once, as the script uses the variables for those pathes. They only need to point to existing folders.