Hi all,

I am trying to dual boot Windows 10 and WinPE, but have it all setup through an automated process using a Batch script.

This is my diskpart script:
Code:
select disk 0
clean
convert GPT
rem === 1. Create the EFI system partition ===
create partition EFI size=200
format quick fs=fat32 label=EFI
assign letter=S
rem === 2. Create the Microsoft reserved partition ===
create partition MSR size=128
rem === 3. Create the Windows PE partition ===
rem (The partition size is set to 400 MB, though a smaller partition size may be used.)
create partition primary size=20000
format quick fs=ntfs label=WinPE
assign letter=C
rem === 4. Create a Windows or data partition ===
rem (This partition fills the rest of the disk.)
create partition primary
format quick fs=ntfs label=Windows
assign letter=W
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
list vol 
exit
This is my Batch Script so far:
Code:
@ECHO ON
START /WAIT DISKPART.exe /S DiskpartHope.txt

xcopy D:\EFI\* S:\EFI\* /cherkyfs
xcopy D:\sources\* C:\sources\* /cherkyfs
copy D:\boot\boot.sdi C:\sources\
copy D:\windows\boot\EFI\*.efi S:\EFI\Microsoft\Boot\*
del S:\EFI\Microsoft\Boot\BCD /f

bcdedit -createstore S:\EFI\Microsoft\Boot\BCD

bcdedit -store S:\EFI\Microsoft\Boot\BCD -create {bootmgr} /d "Boot Manager"
bcdedit -store S:\EFI\Microsoft\Boot\BCD -create {globalsettings} /d "globalsettings"
bcdedit -store S:\EFI\Microsoft\Boot\BCD -create {dbgsettings} /d "debugsettings"
bcdedit -store S:\EFI\Microsoft\Boot\BCD -create {ramdiskoptions} /d "ramdiskoptions"
bcdedit -store S:\EFI\Microsoft\Boot\BCD -create /d "Windows PE" -application osloader>GUID.txt
REM Assign GUID to Variable NEWGUID
For /F "tokens=2 delims={}" %%i in (GUID.txt) do (set newguid=%%i)
bcdedit -store S:\EFI\Microsoft\Boot\BCD /default {%newguid%}

bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {bootmgr} device partition=s:
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {bootmgr} locale en-us
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {bootmgr} timeout 5

bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} device ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} path \windows\system32\winload.efi
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} osdevice ramdisk=[C:]\sources\boot.wim,{ramdiskoptions} 
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} systemroot \windows
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} winpe yes
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} nx optin
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} detecthal yes
bcdedit -store S:\EFI\Microsoft\Boot\BCD -displayorder {Default} -addfirst

bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {dbgsettings} debugtype Serial
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {dbgsettings} debugport 1
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {dbgsettings} baudrate 115200

bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {ramdiskoptions} ramdisksdidevice partition=C: 
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {ramdiskoptions} ramdisksdipath \sources\boot.sdi

XCOPY "%CD%\ImageBackup\Install.wim" "C:\"
REM DISM /apply-image /imagefile:"%CD%\ImageBackup\Install.wim" /index:1 /ApplyDir:W:\
REM bcdboot.exe w:\windows /s s: /f all
pause
exit
So I set up the actual winpe partition and created it's boot store before applying any wims and this works. The problem is, it boots me into WinPE as the default image. It's remarked off, but if I apply the image at the end and run bcdboot, it will default to Windows but the sysprepped first boot fails. Also I have no idea how to get back to my WinPE again. I have to find a way to setup dual boot at this point. I think I need to continue to use a few bcdedit commands to set up both boot items, but I am not sure. Any help with this would be very appreciated.