Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202:::: PROJECT: ReactOS ISO Remastering Script:: LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later):: PURPOSE: Allows easy remastering of customized ReactOS ISO images.:: Based on the boot/boot_images.cmake script in the ReactOS:: source tree. Requires a MKISOFS-compatible utility.:: COPYRIGHT: Copyright 2023-2025 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>::
@echo off:: title ReactOS ISO Remastering Script
setlocal enabledelayedexpansion
:::: Customizable settings:::: ISO image identifier namesset ISO_MANUFACTURER="ReactOS Project"& :: For both the publisher and the preparerset ISO_VOLNAME="ReactOS"& :: For both the Volume ID and the Volume set ID
:: Image names of the MKISOFS and ISOHYBRID toolsset MKISOFS=MKISOFS.EXEset ISOHYBRID=ISOHYBRID.EXE
:::: Main script::clsecho *******************************************************************************echo * *echo * ReactOS ISO Remastering Script *echo * *echo *******************************************************************************echo.
:: Newline macro, see https://stackoverflow.com/a/6379940(set \n=^%=Don't remove this line=%)
:: Verify that we have access to a temporary directory.:: See https://stackoverflow.com/a/21041546 for more details.if defined TEMP ( if exist "%TEMP%\" goto :TEMP0 ) if defined TMP ( if exist "%TMP%\" goto :TEMP1 ) echo No temporary directory exists on your system. echo Please create one and assign it to the TEMP environment variable. echo. goto :Quit :TEMP1 set "TEMP=%TMP%":TEMP0
:: Try to auto-locate MKISOFS and if not, prompt the user for a directory.set TOOL_DIR=set TOOL_PATH=for /f "delims=" %%f in ('WHERE %MKISOFS% 2^>NUL') do ( set "TOOL_DIR=%%~dpf" & if "!TOOL_DIR:~-1!"=="\" set "TOOL_DIR=!TOOL_DIR:~0,-1!" set "TOOL_PATH=%%f" goto :mkisofs_found)if not defined TOOL_PATH ( set /p TOOL_DIR="Please enter the directory path where %MKISOFS% can be found:!\n!" echo. if "!TOOL_DIR:~-1!"=="\" set "TOOL_DIR=!TOOL_DIR:~0,-1!" set "TOOL_PATH=!TOOL_DIR!\%MKISOFS%"):mkisofs_foundset "MKISOFS=%TOOL_PATH%"
set /p INPUT_DIR="Please enter the path of the directory tree to image into the ISO:!\n!"echo.set /p OUTPUT_ISO="Please enter the file path of the ISO image that will be created:!\n!"echo.
:: Retrieve the full paths to the 'isombr', 'isoboot', 'isobtrt' and 'efisys' filesset isombr_file=loader/isombr.binset isoboot_file=loader/isoboot.binset isobtrt_file=loader/isobtrt.binset efisys_file=loader/efisys.bin
set ISOBOOT_PATH=%isoboot_file%::CHOICE /c 12 /n /m "Please choose the ISO boot file: 1) isoboot.bin ; 2) isobtrt.bin!\n![default: 1]: "CHOICE /c YN /n /m "Do you want the ReactOS media to wait for a key-press before booting [Y,N]? "echo.if errorlevel 2 set ISOBOOT_PATH=%isobtrt_file%
:: Enable (U)EFI boot support if possible: check the:: presence of %efisys_file% in the ISO directory tree.:: NOTE: Convert forward to backslashes.::ISO_EFI_BOOT_PARAMSset ISO_BOOT_EFI_OPTIONS=if exist "%INPUT_DIR%\%efisys_file:/=\%" ( set "ISO_BOOT_EFI_OPTIONS=-eltorito-alt-boot -eltorito-platform efi -eltorito-boot %efisys_file% -no-emul-boot")
:: Summary of the boot files.echo ISO boot file: '%ISOBOOT_PATH%'if defined ISO_BOOT_EFI_OPTIONS ( echo EFI boot file: '%efisys_file%')echo.
set DUPLICATES_ONCE=CHOICE /c YN /n /m "Do you want to store duplicated files only once (reduces the size!\n!of the ISO image) [Y,N]? "echo.if %ERRORLEVEL% equ 1 set DUPLICATES_ONCE=-duplicates-once
echo Creating the ISO image...echo.
:: Create a mkisofs sort file to specify an explicit ordering for the boot files:: to place them at the beginning of the image (makes ISO image analysis easier).:: See mkisofs/schilytools/mkisofs/README.sort and boot/boot_images.cmake script:: in the ReactOS source tree for more details.:: https://stackoverflow.com/a/29635767( ::echo ${CMAKE_CURRENT_BINARY_DIR}/empty/boot.catalog 4 echo boot.catalog 4 :: NOTE: Convert forward to backslashes. echo %INPUT_DIR%\%isoboot_file:/=\% 3 echo %INPUT_DIR%\%isobtrt_file:/=\% 2 echo %INPUT_DIR%\%efisys_file:/=\% 1) > "%TEMP%\bootfiles.sort"
:: Finally, create the ISO image proper."%MKISOFS%" ^ -o "%OUTPUT_ISO%" -iso-level 4 ^ -publisher %ISO_MANUFACTURER% -preparer %ISO_MANUFACTURER% ^ -volid %ISO_VOLNAME% -volset %ISO_VOLNAME% ^ -eltorito-boot %ISOBOOT_PATH% -no-emul-boot -boot-load-size 4 ^ %ISO_BOOT_EFI_OPTIONS% ^ -hide boot.catalog -sort "%TEMP%\bootfiles.sort" ^ %DUPLICATES_ONCE% -no-cache-inodes "%INPUT_DIR%":: -graft-points -path-list "some/directory/iso_image.lst"echo.
if errorlevel 1 (del "%TEMP%\bootfiles.sort" echo An error %ERRORLEVEL% happened while creating the ISO image "%OUTPUT_ISO%". goto :Quit) else (del "%TEMP%\bootfiles.sort" echo The ISO image "%OUTPUT_ISO%" has been successfully created.)echo.
:: Check whether ISOHYBRID is also available and if so, propose to post-process:: the generated ISO image to allow hybrid booting as a CD-ROM or as a hard disk.set TOOL_PATH=for /f "delims=" %%f in ('WHERE "%TOOL_DIR%":%ISOHYBRID% 2^>NUL') do ( set "TOOL_PATH=%%f" & goto :isohybrid_found)if not defined TOOL_PATH ( for /f "delims=" %%f in ('WHERE %ISOHYBRID% 2^>NUL') do ( set "TOOL_PATH=%%f" goto :isohybrid_found ) if not defined TOOL_PATH ( echo %ISOHYBRID% patching skipped. goto :Success )):isohybrid_foundset "ISOHYBRID=%TOOL_PATH%"
CHOICE /c YN /n /m "Do you want to post-process the ISO image to allow hybrid booting!\n!as a CD-ROM or as a hard disk [Y,N]? "echo.if %ERRORLEVEL% neq 1 goto :Success
echo Patching the ISO image...
:: NOTE: Convert forward to backslashes."%ISOHYBRID%" -b %INPUT_DIR%\%isombr_file:/=\% -t 0x96 "%OUTPUT_ISO%"echo.
if errorlevel 1 ( echo An error %ERRORLEVEL% happened while patching the ISO image "%OUTPUT_ISO%". goto :Quit):: else (:: echo The ISO image "%OUTPUT_ISO%" has been successfully patched.:: ):: echo.
:Successecho Success^^!:Quitendlocalecho Press any key to quit...pause > NULexit /b