Skip to content

Instantly share code, notes, and snippets.

@p0w3rsh3ll
Created Mar 27, 2017
Embed
What would you like to do?
@echo off
:: Calculate the current directory (containing this file).
set _WHEREAMI=%~d0%~p0
set _WHEREAMI=%_WHEREAMI:"=%
if not exist c:\temp\hotfix\*%1*.cab echo c:\temp\hotfix\*%1*.cab not found & goto finish
for /f %%z in ('dir c:\temp\hotfix\*%1*.cab /S/A/B') do @ set _HotFx=%%z
echo -Dealing with %_HotFx%-
set _WAIKLOCATION=%programfiles%\Windows AIK
if "%PROCESSOR_ARCHITECTURE%"=="x86" set Path=%_WAIKLOCATION%\Tools\PETools;%_WAIKLOCATION%\Tools\x86;%_WAIKLOCATION%\Tools\x86\Servicing;%PATH%
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set Path=%_WAIKLOCATION%\Tools\PETools;%_WAIKLOCATION%\Tools\AMD64;%_WAIKLOCATION%\Tools\x86;%_WAIKLOCATION%\Tools\AMD64\Servicing;%_WAIKLOCATION%\Tools\x86\Servicing;%PATH%
:: boot.wim index:1
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /Mount-WIM /WimFile:c:\temp\src\sources\boot.wim /Index:1 /MountDir:c:\temp\mount
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /Image:C:\temp\mount /Add-Package /PackagePath:%_HotFx%
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /unmount-Wim /MountDir:"C:\temp\mount" /Commit
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
:: boot.wim index:2
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /Mount-WIM /WimFile:c:\temp\src\sources\boot.wim /Index:2 /MountDir:c:\temp\mount
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /Image:C:\temp\mount /Add-Package /PackagePath:%_HotFx%
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
robocopy C:\temp\mount\sources c:\temp\src\sources /r:0 /Z /XO /XF background.bmp
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /unmount-Wim /MountDir:"C:\temp\mount" /Commit
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
:: install.wim index:1 and winre.wim
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /Mount-WIM /WimFile:c:\temp\src\sources\install.wim /Index:1 /MountDir:c:\temp\mount
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /Image:C:\temp\mount /Add-Package /PackagePath:%_HotFx%
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /Mount-WIM /WimFile:c:\temp\mount\windows\system32\recovery\winre.wim /Index:1 /MountDir:c:\temp\winremount
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /Image:c:\temp\winremount /Add-Package /PackagePath:%_HotFx%
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /unmount-Wim /MountDir:"c:\temp\winremount" /Commit
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
"%_WAIKLOCATION%\Tools\Servicing\Dism.exe" /unmount-Wim /MountDir:"C:\temp\mount" /Commit
if not "%errorlevel%"=="0" echo Error %errorlevel% & goto error
goto finish
:error
echo aborting...
:finish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment