@echo off setlocal rem Source drive, Destination drive set src=S: set dst=T: set bcdentry={default} set bcddrive=%dst% echo List of files to be copied xcopy %src%\ %dst%\ /exclude:%~dp0\cloneexclude.txt /e /c /i /h /k /x /y /b /l echo Copy files from %src% to %dst% xcopy %src%\ %dst%\ /exclude:%~dp0\cloneexclude.txt /e /c /i /h /k /x /y /b /w echo Make sure boot manager are not compressed. compact /u %dst%\bootmgr %dst%\ntldr %dst%\grldr.* %dst%\menu.lst echo Adjust \DosDevices\C: value set dstsignature= for /f "skip=2 tokens=1,2,*" %%I in ('reg query HKLM\SYSTEM\MountedDevices /v \DosDevices\%dst%') do ( set dstsignature=%%K ) reg load HKLM\systemdst %dst%\Windows\system32\config\system reg add HKLM\systemdst\MountedDevices /v \DosDevices\C: /t REG_BINARY /d %dstsignature% /f reg query HKLM\systemdst\MountedDevices /v \DosDevices\C: reg unload HKLM\systemdst echo Copy bootmgr, BCD to %bcddrive% if not exist %bcddrive%\bootmgr xcopy %src%\bootmgr %bcddrive%\bootmgr /c /h /k /x /y if not exist %bcddrive%\Boot\BCD xcopy %src%\Boot\ %dst%\Boot\ /e /c /i /h /k /x /y /b if not exist %bcddrive%\Boot\BCD goto endbcd echo Update BCD entry. bcdedit /store %bcddrive%\Boot\BCD /set {bootmgr} device partition=%bcddrive% bcdedit /store %bcddrive%\Boot\BCD /set %bcdentry% device partition=%dst% bcdedit /store %bcddrive%\Boot\BCD /set %bcdentry% osdevice partition=%dst% bcdedit /store %bcddrive%\Boot\BCD /set %bcdentry% detecthal yes bcdedit /store %bcddrive%\Boot\BCD :endbcd endlocal