@echo off
cd /d "%~dp0"
If Exist "%~dp0BCD" del /f /q "%~dp0BCD"
for %%I in (*.wim) do call :creat %%~nI %%~nxI
del /q /f /ah "%~dp0*.log" 2>nul 1>&2
Goto eof
:creat
set BCD=bcdedit.exe /store "%~dp0BCD"
If DEFINED %1 goto eof
If NoT Exist "%~dp0BCD" (bcdedit /createstore "%~dp0BCD" 2>nul 1>&2
for /f "tokens=2 delims={}" %%a in ('%BCD% /create {bootmgr} /d "Windows Boot Manager"') do (
%BCD% /set {%%a} inherit {globalsettings} 2>nul 1>&2
%BCD% /set {%%a} locale ru_RU 2>nul 1>&2
%BCD% /set {%%a} PrereleaseSignatures yes 2>nul 1>&2
%BCD% /set {%%a} nointegritychecks yes 2>nul 1>&2
%BCD% /set {%%a} loadoptions DDISABLE_INTEGRITY_CHECKS 2>nul 1>&2
%BCD% /set {%%a} fontpath \_WIM\BOOT\Fonts 2>nul 1>&2
%BCD% /set {%%a} Timeout 30 2>nul 1>&2
%BCD% /set {%%a} DisplayOrder {current} 2>nul 1>&2
)
If Exist "%~dp0BOOT\memtest.exe" (
for /f "tokens=2 delims={}" %%i in ('%BCD% /create {memdiag} /d "Диагностика памяти"') do (
%BCD% /set {%%i} Device boot 2>nul 1>&2
%BCD% /set {%%i} Path \_WIM\BOOT\memtest.exe 2>nul 1>&2
%BCD% /set {%%i} inherit {globalsettings} 2>nul 1>&2
%BCD% /set {%%i} nointegritychecks yes 2>nul 1>&2
%BCD% /set {%%i} BadMemoryAccess yes 2>nul 1>&2
%BCD% /set {%%i} loadoptions DDISABLE_INTEGRITY_CHECKS 2>nul 1>&2
%BCD% /set {bootmgr} ToolsDisplayOrder {memdiag} 2>nul 1>&2
)
)
for /f "tokens=2 delims={}" %%j in ('%BCD% /create {ramdiskoptions}') do (
%BCD% /set {%%j} ramdisksdidevice Boot 2>nul 1>&2
%BCD% /set {%%j} ramdisksdipath \_WIM\BOOT\boot.sdi 2>nul 1>&2
)
for /f "tokens=2 delims={}" %%k in ('%BCD% /create {bootloadersettings}') do (
%BCD% /set {%%k} fontpath \_WIM\BOOT\Fonts 2>nul 1>&2
%BCD% /set {%%k} inherit {globalsettings} 2>nul 1>&2
)
)
for /f "tokens=2 delims={}" %%b in ('%BCD% /create /d ">>> %1" /application osloader') do (
%BCD% /set {%%b} osdevice ramdisk=[boot]\_WIM\%2,{ramdiskoptions} 2>nul 1>&2
%BCD% /set {%%b} inherit {globalsettings} 2>nul 1>&2
%BCD% /set {%%b} locale ru-RU 2>nul 1>&2
%BCD% /set {%%b} nointegritychecks yes 2>nul 1>&2
%BCD% /set {%%b} testsigning yes 2>nul 1>&2
%BCD% /set {%%b} bootmenupolicy legacy 2>nul 1>&2
%BCD% /set {%%b} loadoptions DDISABLE_INTEGRITY_CHECKS 2>nul 1>&2
%BCD% /set {%%b} detecthal yes 2>nul 1>&2
%BCD% /set {%%b} winpe yes 2>nul 1>&2
%BCD% /set {%%b} path "\Windows\system32\boot\winload.exe" 2>nul 1>&2
%BCD% /set {%%b} device ramdisk=[boot]\_WIM\%2,{ramdiskoptions} 2>nul 1>&2
%BCD% /set {%%b} systemroot "\Windows" 2>nul 1>&2
%BCD% /displayorder {%%b} /addlast 2>nul 1>&2
%BCD% /set {%%b} nx OptIn 2>nul 1>&2
)
exit /b