Jump to content

AIO DVD Build - DISM Acting Up


Recommended Posts

I have built myself a small DISM script to unpack a clean Windows 7 SP1 image and compile an up to date disc, which I run every month. I have gotten to the point where I am running it over and over again, taking days, just waiting for the one time it works. Eventually it always does.


:INSTALL_WIM
SET INDEX=%1
ECHO.
@TITLE Building^ Windows^ %WINVER%^ AIO^ Disc^ -^ Image^ %INDEX%^ of^ %INDEX_TOTAL%
FOR /F "tokens=*" %%A IN ('DISM /Get-WimInfo /WimFile:"%DVDROOT%\sources\install.wim" /Index:%INDEX% ^| FIND /I "Name"') DO SET EDITION=%%A
SET EDITION=%EDITION:Name : =%
FOR /F "tokens=*" %%A IN ('DISM /Get-WimInfo /WimFile:"%DVDROOT%\sources\install.wim" /Index:%INDEX% ^| FIND /I "Architecture"') DO SET MOUNT_BIT=%%A
SET MOUNT_BIT=%MOUNT_BIT:Architecture : =%
ECHO Image %INDEX% of %INDEX_TOTAL%: %EDITION% %MOUNT_BIT%
ECHO - Mounting Image...
MKDIR "%MOUNT_DIR%" >NUL
%DISM% /mount-wim /wimfile:"%DVDROOT%\sources\install.wim" /index:%INDEX% /mountdir:"%MOUNT_DIR%" >NUL
IF EXIST "%UPDATES%\ie" ECHO - Adding Latest Internet Explorer...& FOR %%b IN ("%UPDATES%\ie\*%MOUNT_BIT%*.*") DO %DISM% /Image:"%MOUNT_DIR%" /Add-Package /PackagePath:"%%b" >NUL 2>&1
FOR /F "tokens=*" %%a in ('dir /b /A-d "%UPDATES%\*%MOUNT_BIT%*" ^| find "" /v /n /c') DO SET UPDATE_TOTAL=%%a>NUL
SET COUNT=0
FOR %%b IN ("%UPDATES%\*%MOUNT_BIT%*.*") DO (
SET /A COUNT+=1
SET /P "=.%BS% - Adding Update !COUNT! of %UPDATE_TOTAL%...!CR!" <NUL

=====MAIN PART HERE=====

%DISM% /Image:"%MOUNT_DIR%" /Add-Package /PackagePath:"%%b" >NUL 2>&1
IF NOT ERRORLEVEL 0 ECHO Index:%INDEX% %MOUNT_BIT% !COUNT! !ERRORLEVEL! Update:%%b >> "%ERROR_LOG%"

=====END MAIN PART=====
)
ECHO - Adding Update %COUNT% of %UPDATE_TOTAL%...
IF /I "%WINVER%" == "Vista" Call :DRIVERS_VISTA
IF /I NOT "%WINVER%" == "Vista" Call :Drivers
IF EXIST "%ERROR_LOG%" ECHO. >> "%ERROR_LOG%"
%DISM% /Image:"%MOUNT_DIR%" /Set-TimeZone:"Eastern Standard Time" >NUL 2>&1
%DISM% /Image:"%MOUNT_DIR%" /Set-UILang:en-US >NUL 2>&1
%DISM% /Image:"%MOUNT_DIR%" /Set-SysLocale:en-CA >NUL 2>&1
%DISM% /Image:"%MOUNT_DIR%" /Set-UserLocale:en-CA >NUL 2>&1
%DISM% /Image:"%MOUNT_DIR%" /Set-InputLocale:1009:409 >NUL 2>&1
IF EXIST "%MOUNT_DIR%\Users\Public\Music\Sample Music" RD "%MOUNT_DIR%\Users\Public\Music\Sample Music" /S /Q >NUL 2>&1
IF EXIST "%MOUNT_DIR%\Users\Public\Pictures\Sample Pictures" RD "%MOUNT_DIR%\Users\Public\Pictures\Sample Pictures" /S /Q >NUL 2>&1
IF EXIST "%MOUNT_DIR%\Users\Public\Videos\Sample Videos" RD "%MOUNT_DIR%\Users\Public\Videos\Sample Videos" /S /Q >NUL 2>&1
ECHO - Saving ^& Un-Mounting Image...
%DISM% /unmount-wim /mountdir:"%MOUNT_DIR%" /commit >NUL
RD /S /Q "%MOUNT_DIR%" >NUL
%DISM% /cleanup-wim >NUL
IF EXIST "%MOUNT_DIR%" ECHO ERROR! %MOUNT_DIR% cannot be deleted.& pause
goto :eof

My custom error log, which basically just tells me if I have an error or not, shows this:


[no problems with index 1-7]
Index:8 x64 1 -2146498512 Update:C:\WinAIO\Updates\7\IE9-Windows6.1-KB2761451-x64.cab
Index:8 x64 2 -2146498512 Update:C:\WinAIO\Updates\7\Windows-LocalPack-CA-Package-x64.cab
Index:8 x64 3 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2189014-v2-x64.cab
Index:8 x64 4 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2276594-x64.cab
ect....
Index:9 x64 1 -2146498512 Update:C:\WinAIO\Updates\7\IE9-Windows6.1-KB2761451-x64.cab
Index:9 x64 2 -2146498512 Update:C:\WinAIO\Updates\7\Windows-LocalPack-CA-Package-x64.cab
Index:9 x64 3 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2189014-v2-x64.cab
Index:9 x64 4 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2276594-x64.cab
ect....

and the next time like this:


[no problems with index 1 or 2, or updates 1 - 203]
Index:3 x86 204 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2673042-v2-x86.cab
Index:3 x86 205 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2674365-x86.cab
Index:3 x86 206 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2674705-x86.cab
Index:3 x86 207 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2674913-x86.cab
Index:3 x86 208 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2675275-x86.cab
Index:3 x86 209 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2675611-x86.cab
Index:3 x86 210 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2675806-x86.cab
Index:3 x86 211 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2676562-x86.cab
Index:3 x86 212 -2146498512 Update:C:\WinAIO\Updates\7\Windows6.1-KB2679255-v2-x86.cab
ect....
[no problems with index 4-9]

So I can keep multiple install.wim's around and keep exporting the images that worked into a final image, all done manually, but DONE MANUALLY? yeah not cool. A snippet from the DISM log has been attached.

Why does this seem to work sometimes, but not all the time? I also use this script to update Windows Vista and 8, again sometimes working sometimes not. I am running Windows 7 Ultimate x64 with all updates and my antivirus disabled (Symantec Endpoint Protection). Windows 8 ADK is installed, I wanted to see if it fixed this problem. It didn't. Once in a while unmounting an image will also fail claiming files are in use, which they shouldn't be. I've tried finding the services responsible and I can't. Unlocker can't identify the process or remove the files manually without rebooting.

I am not dual booting or booting from a VHD or anything advanced. It's a very simple setup with one partition, one user account (admin with UAC disabled). I have a Lenovo T520 i5-2520M 8GB with OCZ 256GB Vertex 3 SSD.

I'm not sure if any other information is relevant. Does anyone else have a similar issue? I have no idea what is going on.

EDIT: In retrospect I probably should have put this in the Unattended forum, although my question isn't exactly about the unattended process. MOD feel free to move as required.

Edited by RaynotRoy
Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...