Add Windows PreInstallation Environment to boot menu for installing Windows 11 from partition or from external usb bootable drive.


Ramesh Sharma

Active member
Member
Local time
7:46 PM
Posts
133
OS
Window 11 v24H2 Build 26085.1
Please Note:- 1. Use 16 gb usb drive or 10 gb partition on hard drive for this process.
2. Backup bcd file using command bcdedit /export c:\11May23.bcd
(Use filename and location according to your comfort. )
3. After adding Windows Preinstallation Environment to main boot menu, bootmenu display will be in legacy mode.
4. If main os is kept as default in boot menu, standard mode will be seen without Windows Preinstallation Environment.
5. You can import bcdbackup if you do not want legacy boot mode and want to restore your previous boot menu back.
6. Adding Windows Preinstallation Environment to main boot menu is useful when we have no bootable drive as Windows 11 will be installed from partition on hard drive. To install from this Windows Preinstallation Environment via bootable drive, keep the usb drive attached to cabinet. No need to change boot order from bios.
Prepare 16 gb bootable drive by following method:-
Run CMD as administrator from Windows 11. Press enter after each command.
diskpart
list disk
select disk 1
clean
convert mbr
create partition primary size=2048
create partition primary
list partition
select partition 1
format fs=fat32 label="BOOT" quick
assign letter=Y
active
select partition 2
format fs=ntfs label="INSTALL" quick
assign letter=Z
exit
Then boot from this usb drive by changing the boot order in bios.
At install screen , press Shift+F10 to bring up command prompt as administrator.
x:\sources>cd \
x:>dir
You will see Windows directory(size approximately 1.9 gb). We have to copy this directory to Z: (If using partition of 10 gb size, run diskpart >list vol and then note this partition letter.Copy this Windows directory to partition you noted.This will be added to folders and files copied from mounted iso of Windows 11.)
x:>xcopy x:\windows Z:\windows /e /h
Press enter to copy windows directory to usb drive ntfs partition Z:\windows.
OR
x:>notepad
File >look in Boot(X:) , Select Windows . Right click>Send To Z: (may be different in your pc.)
Windows directory will be copied to Z:
Apply any of the two methods to copy Windows directory to usb drive or partition.
Then run this command:-
x:\sources>bcdboot Z:\Windows (for usb drive partition)
x:\sources>bcdboot E:\Windows (for partition on hard drive, may be different in your case.)
We can run this command from Windows desktop after running CMD as administrator, as below(for partition on hard drive only)
C:\windows\system32>bcdboot E:\Windows (assuming partition letter is E: of size 10 gb having windows directory copied and, all folders and files copied from mounted iso of Windows 11)
At the end of process, reboot and change boot order as hard drive as first sequence.
Separate boot entries will be seen for Windows PreInstallation Environment. Two boot entries, one for usb drive and second for partition.
Keep bootable usb drive attached to cabinet while restarting the machine.
I treid to bring standard boot menu back by running following command as administrator from desktop:-
C:\windows\system32>bcdedit /Set {Current} BootMenuPolicy Standard
OR
C:\windows\system32>bcdedit /Set {default} BootMenuPolicy Standard.
But could not bring back Standard mode.
So it is best to backup BCD. I have assumed that all file and folders are copied to Z: from mounted iso of Windows 11.
And all folders and file ,excluding sources folder, are copied to Y: No need to copy boot.wim to Y: as we have done in earlier cases.
Thanks for reading this thread.
 
Windows Build/Version
Windows 11 v22H2 OS build 1555
Last edited:

My Computer

System One

  • OS
    Window 11 v24H2 Build 26085.1
    Computer type
    PC/Desktop
    Manufacturer/Model
    ASSEMMBLED
    CPU
    Intel Pentium CPU G620@ 2.60 GHz
    Motherboard
    DAICHI
    Memory
    6 GB
    Graphics Card(s)
    Onboard
    Sound Card
    Onboard
    Monitor(s) Displays
    LG
    Screen Resolution
    1366x768
    Hard Drives
    Toshiba HDD 1 TB
    Keyboard
    Mechanical
    Mouse
    Mechanical
    Internet Speed
    700 kb/s
    Browser
    Microsoft EDGE, CHROME
    Antivirus
    Microsoft Defender
If any usb drive has 8 to 10 GB free unallocated space , then format this partition as NTFS (say M:)
Copy all files and folders of mounted Windows 11 iso to this partition M:
Now boot from Windows 11 bootable drive and press Shift + F10 key to bring command prompt as administrator.[ I made Windows 11 media usb by media creation tool from Microsoft website which used 32 gb off 64 gb drive to format as FAT 32 partition. This partition is to be used for this process described below. Rest of the partition nearly 29 Gb was left as an unallocated.]
x:\sources>cd \
x:>dir
You will see Windows directory(size approximately 1.92 gb). We have to copy this directory to Z: (If using partition of 10 gb size, run diskpart >list vol and then note this partition letter , suppose noted as Z: Copy this Windows directory to partition you noted.This will be added to folders and files copied from mounted iso of Windows 11.) This may be different in disk management service while format.
x:>xcopy x:\windows Z:\windows /e /h
Press enter to copy windows directory to usb drive ntfs partition Z:\windows.
Then run this command:-
x:\sources>bcdboot Z:\Windows (for usb drive partition)
Windows Preinstallation Environment is now added to main bootloader to install Windows 11.
Please note this works slower, so be patient to install Windows 11 from a non bootable partition
.
Thanks for reading.
 

Attachments

  • IMG_20230530_215841_733.jpg
    IMG_20230530_215841_733.jpg
    1.1 MB · Views: 3

My Computer

System One

  • OS
    Window 11 v24H2 Build 26085.1
    Computer type
    PC/Desktop
    Manufacturer/Model
    ASSEMMBLED
    CPU
    Intel Pentium CPU G620@ 2.60 GHz
    Motherboard
    DAICHI
    Memory
    6 GB
    Graphics Card(s)
    Onboard
    Sound Card
    Onboard
    Monitor(s) Displays
    LG
    Screen Resolution
    1366x768
    Hard Drives
    Toshiba HDD 1 TB
    Keyboard
    Mechanical
    Mouse
    Mechanical
    Internet Speed
    700 kb/s
    Browser
    Microsoft EDGE, CHROME
    Antivirus
    Microsoft Defender
Have you tried extracting boot.wim with 7-zip for flat booting pe or applying it with dism or similar
 

My Computers

System One System Two

  • OS
    Win7
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • Operating System
    win7
    Computer type
    PC/Desktop
    CPU
    pentium g5400
    Motherboard
    gigabyte b365m ds3h
    Memory
    1x8gb 2400
    PSU
    xfx pro 450
Have you tried extracting boot.wim with 7-zip for flat booting pe or applying it with dism or similar
Thanks for reading. Suggested methods are always welcome.
Is there any way to add Windows Preinstallation Environment in standard mode to main bootloader.
My pc has 2 Tb hard disk , MBR style.
 

My Computer

System One

  • OS
    Window 11 v24H2 Build 26085.1
    Computer type
    PC/Desktop
    Manufacturer/Model
    ASSEMMBLED
    CPU
    Intel Pentium CPU G620@ 2.60 GHz
    Motherboard
    DAICHI
    Memory
    6 GB
    Graphics Card(s)
    Onboard
    Sound Card
    Onboard
    Monitor(s) Displays
    LG
    Screen Resolution
    1366x768
    Hard Drives
    Toshiba HDD 1 TB
    Keyboard
    Mechanical
    Mouse
    Mechanical
    Internet Speed
    700 kb/s
    Browser
    Microsoft EDGE, CHROME
    Antivirus
    Microsoft Defender
Is there any way to add Windows Preinstallation Environment in standard mode to main bootloader.
Yes. Add a winpe entry to the current bcd store. Point it at boot.sdi and boot.wim on the partition.
 
Last edited:

My Computers

System One System Two

  • OS
    Win7
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • Operating System
    win7
    Computer type
    PC/Desktop
    CPU
    pentium g5400
    Motherboard
    gigabyte b365m ds3h
    Memory
    1x8gb 2400
    PSU
    xfx pro 450
Easier to use a batch file than typing all the commands individually.

For example

Copy boot.wim and boot.sdi to partition R.

Adjust the paths below to wherever your boot.wim and boot.sdi are located.

set pedrive=R:
set pewimpath=\boot.wim
set sdipath=\BOOT.SDI
set mydescription=WHATEVER NAME YOU LIKE

Copy the code below to a text file and save it as add-pe-to-bcd.cmd

Code:
@ECHO OFF

set pedrive=R:
set pewimpath=\boot.wim
set sdipath=\BOOT.SDI
set mydescription=WHATEVER NAME YOU LIKE

IF NOT EXIST %PEDRIVE%%PEWIMPATH% (
 ECHO %PEDRIVE%%PEWIMPATH%  DOES NOT EXIST
 GOTO :failed
  )
  IF NOT EXIST %PEDRIVE%%SDIPATH% (
 ECHO %PEDRIVE%%SDIPATH%  DOES NOT EXIST
 GOTO :failed
  )
echo.
(set WLOADER=)
for /f "usebackq tokens=1,2" %%G in (`bcdedit.exe /enum {current} ^| find "path"`) do set WLOADER=%%H
if "%WLOADER%"=="" (
 ECHO LOADER NOT FOUND
 goto :failed
   )
ECHO.
 (set LCAL=)
for /f "usebackq tokens=1,2" %%G in (`bcdedit.exe /enum {current} ^| find "locale"`) do set LCAL=%%H
ECHO.
echo windows loader is is %wloader%
echo.
echo locale is %lcal%
echo.
pause
echo.
for /f "tokens=2 delims={}" %%a in ('BCDEDIT /create /device') do set newramdiskguid=%%a
echo.
echo new ramdisk guid is %newramdiskguid%
echo.
bcdedit.exe -set {%newramdiskguid%} ramdisksdidevice partition=%PEDRIVE%
bcdedit.exe -set {%newramdiskguid%} ramdisksdipath %SDIPATH%
bcdedit.exe -set {%newramdiskguid%} description "%mydescription%"
echo.
for /f "tokens=2 delims={}" %%g in ('BCDEDIT /create /application osloader') do set newloaderguid=%%g
echo.
echo new loader guid is %newloaderguid%
echo.
    bcdedit.exe -set {%newloaderguid%} path %WLOADER%
    bcdedit.exe -set {%newloaderguid%} locale %LCAL%
    bcdedit.exe -set {%newloaderguid%} systemroot \Windows
    bcdedit.exe -set {%newloaderguid%} detecthal Yes
    bcdedit.exe -set {%newloaderguid%} winpe Yes
    bcdedit.exe -set {%newloaderguid%} osdevice ramdisk=[%PEDRIVE%]%PEWIMPATH%,{%newramdiskguid%}
    bcdedit.exe -set {%newloaderguid%} device ramdisk=[%PEDRIVE%]%PEWIMPATH%,{%newramdiskguid%}
    bcdedit.exe -set {%newloaderguid%} description "%mydescription%"
    bcdedit.exe -displayorder {%newloaderguid%} /addlast
echo done
pause

:failed
pause
 
Last edited:

My Computers

System One System Two

  • OS
    Win7
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • Operating System
    win7
    Computer type
    PC/Desktop
    CPU
    pentium g5400
    Motherboard
    gigabyte b365m ds3h
    Memory
    1x8gb 2400
    PSU
    xfx pro 450
Back
Top Bottom