Skip to content

Instantly share code, notes, and snippets.

@Diskmaster
Last active May 18, 2019 07:14
Show Gist options
  • Save Diskmaster/fae4969a41fcc7240c3d950f90c87970 to your computer and use it in GitHub Desktop.
Save Diskmaster/fae4969a41fcc7240c3d950f90c87970 to your computer and use it in GitHub Desktop.
@echo off
set filename=%~n0
rem %~n0 obtains the filename, without the .bat extension.
set realname=%filename:~0,-6%
rem This step cuts the .RUNME from the batch filename.
set patchname=%realname%.patch
rem And with the cut realname, add the .patch extension.
rem echo DEBUG %filename% %realname% %patchname%
rem Debugging statement, uncomment if you want to see it in action.
echo Patching with %patchname% ...
xdelta3.exe -d %patchname% 2> NUL
if %ERRORLEVEL%==9009 goto missingxdelta
if %ERRORLEVEL%==1 goto patchfailed
echo.
echo Done!
echo.
ping -n 3 127.0.0.1>nul
pause
goto :end
:missingxdelta
echo.
echo Unable to find the xdelta patching utility anywhere in your PATH.
echo Download a copy from http://xdelta.org and put it somewhere in your PATH,
echo the folder you tend to put the raw and patch in is a good candidate. Another
echo reasonable candidate is C:\Windows\system32\
echo.
echo Your current PATH is: %PATH%
echo.
ping -n 3 127.0.0.1>nul
pause
goto :end
:patchfailed
echo.
echo The xdelta patching utility was unable to apply the patch. Make sure the original,
echo unedited raw file and the patch are all in the same folder as this script before
echo attempting to run again.
echo.
ping -n 3 127.0.0.1>nul
pause
goto :end
:end
echo.
rem pause - Why are we pausing twice?
rem Updated by Diskmaster / @TomeofElectrum for Over-Time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment