New
#11
The script I had made had errors and it changed the entry of the main BCD and I got scared, I didn't know what had happened. Luckily I had a backup of the BCD and I restored it before restarting. But I think it only changed the description of the main OS.
I have added BCD backupCode:@echo off Rem check amministrative privileges >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" if '%errorlevel%' NEQ '0' Echo Run with amministrative privileges! & pause & exit Rem Set the destination dir of .vhdx file set "vhdx_dir=C:\VHD" Rem Set the path of Install.wim ::set "wim_dir=I:\sources" Rem Set the index of version to install set "index=8" Rem Set the boot description set "boot_desc=W10 PRO EN-GB (VHD)" mkdir %vhdx_dir% cd /D %vhdx_dir% Rem Backup BCD if NOT EXIST %vhdx_dir%\backup_BCD.bcd ( bcdedit /export %vhdx_dir%\backup_BCD.bcd if '%errorlevel%' NEQ '0' echo( & echo ###### Error! ###### & pause & exit ) if NOT EXIST %vhdx_dir%\backup_BCD.bcd (echo ERROR: BCD backup failed! & exit) else echo Found BCD backup. ( echo create vdisk file="%vhdx_dir%\DualBoot.vhdx" maximum=51200 type=expandable echo attach vdisk echo create partition primary echo format label="DualBootVHD" quick echo assign letter=W echo exit ) >"VHDConfig.txt" start /B /wait diskpart /s VHDConfig.txt if '%errorlevel%' NEQ '0' echo( & echo ###### Error! ###### & pause & exit start /B /wait dism /apply-image /imagefile:%wim_dir%\install.wim /index:%index% /applydir:W:\ if '%errorlevel%' NEQ '0' echo( & echo ###### Error! ###### & pause & exit start /B /wait bcdboot W:\Windows if '%errorlevel%' NEQ '0' echo( & echo ###### Error! ###### & pause & exit start /B /wait bcdedit /set {default} description "%boot_desc%" if '%errorlevel%' NEQ '0' echo( & echo ###### Error! ###### & pause & exit cls echo. echo Windows deployed to VHD file echo and added to host boot menu. echo. pause exit
Last edited by einstein1969; 01 Aug 2020 at 12:34.