DualBoot Windows 10 with native boot on vhdx file.

Page 2 of 2 FirstFirst 12

  1. Posts : 15,441
    Windows10
       #11

    Kari said:
    I put the VHD entry first / default on purpose. First OOBE boot requires a few restarts, having new VHD entry as default I don't have to remain on PC to choose it after every restart when boot menu is shown.

    I can always change the order and change default OS when VHD has been fully setup and booted to desktop first time.

    Kari
    Everybody has different reasons. I have had issues in past where a VHD has not properly installed and pc BSODs, and for some reason bcd gets scrambled. No idea why but after doing it my way, I was always able to boot to original OS.
      My Computer


  2. Posts : 250
    Windows 10 22H2
    Thread Starter
       #12

    cereberus said:
    Everybody has different reasons. I have had issues in past where a VHD has not properly installed and pc BSODs, and for some reason bcd gets scrambled. No idea why but after doing it my way, I was always able to boot to original OS.
    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.

    Code:
    @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
    I have added BCD backup
    Last edited by einstein1969; 01 Aug 2020 at 12:34.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 00:51.
Find Us




Windows 10 Forums