7

I have multiple Operating systems installed, each with their respective EFI file in the ESP (EFI System Partition).

For example: I have Windows 10 at \EFI\Boot\Microsoft\bootmgr.efi, and I have WinPE at \EFI\WinPE\Boot\bootx64.efi

When I boot into my BIOS I can see the list of operating systems, but I would like to be able to give windows a command to change the order and then shutdown, effectively telling Windows to boot into a different operating system.

ᄂ ᄀ
  • 4,187
Dylan
  • 293

2 Answers2

9

This is not documented anywhere by Microsoft. However I was able to look through the source code of Grub2Win to see how they accomplished switching order.

Aparrently there is a bcdedit object called {fwbootmgr} if you change the display order of that item, it will effectively change the Boot order within the UEFI.

bcdedit /set {fwbootmgr} displayorder <ID_OF_NEW_OS> {bootmgr}

You can get the id of the other UEFI entries by doing: bcdedit /enum {fwbootmgr} and looking at the boot entries under displayorder.

Dylan
  • 293
0

Note: The commands below were entered in an Administrator Command Prompt window.

Changing the Default to Boot in the Windows Boot Manager

This was tested using Windows 11 (23H2 v2). A dual boot with Windows 10 was setup in a VirtualBox VM in order create an example to use in this answer. Windows 11 and Windows 10 were installed on different drives.

The command below lists all operating systems stored in the BCD and the current default to boot.

bcdedit

Example output is shown below.


Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume1
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {current}
resumeobject            {b582da06-8fb9-11ef-9705-ab9ecf0bc7c4}
displayorder            {current}
                        {b582da03-8fb9-11ef-9705-ab9ecf0bc7c4}
toolsdisplayorder       {memdiag}
timeout                 30

Windows Boot Loader

identifier {current} device partition=C: path \Windows\system32\winload.efi description Windows 11 locale en-US inherit {bootloadersettings} recoverysequence {b582da08-8fb9-11ef-9705-ab9ecf0bc7c4} displaymessageoverride Recovery recoveryenabled Yes isolatedcontext Yes allowedinmemorysettings 0x15000075 osdevice partition=C: systemroot \Windows resumeobject {b582da06-8fb9-11ef-9705-ab9ecf0bc7c4} nx OptIn bootmenupolicy Standard

Windows Boot Loader

identifier {b582da03-8fb9-11ef-9705-ab9ecf0bc7c4} device partition=D: path \Windows\system32\winload.efi description Windows 10 locale en-US inherit {bootloadersettings} recoverysequence {b582da04-8fb9-11ef-9705-ab9ecf0bc7c4} displaymessageoverride Recovery recoveryenabled Yes isolatedcontext Yes allowedinmemorysettings 0x15000075 osdevice partition=D: systemroot \Windows resumeobject {b582da02-8fb9-11ef-9705-ab9ecf0bc7c4} nx OptIn bootmenupolicy Standard

You can compare the output from the previous command to what appears in the Windows Boot Manager shown in the image below.

The command to make Windows 10 the default to boot is given below.

bcdedit /default {b582da03-8fb9-11ef-9705-ab9ecf0bc7c4} 

The change can be confirmed by entering the command below.

bcdedit /v | find "default "

Example output is shown below.

default                 {b582da03-8fb9-11ef-9705-ab9ecf0bc7c4}

Or you could renter the bcdedit command. Example output is shown below. Note that the id for Windows 10 has changed to {default}.


Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume1
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {default}
resumeobject            {b582da06-8fb9-11ef-9705-ab9ecf0bc7c4}
displayorder            {current}
                        {default}
toolsdisplayorder       {memdiag}
timeout                 30

Windows Boot Loader

identifier {current} device partition=C: path \Windows\system32\winload.efi description Windows 11 locale en-US inherit {bootloadersettings} recoverysequence {b582da08-8fb9-11ef-9705-ab9ecf0bc7c4} displaymessageoverride Recovery recoveryenabled Yes isolatedcontext Yes allowedinmemorysettings 0x15000075 osdevice partition=C: systemroot \Windows resumeobject {b582da06-8fb9-11ef-9705-ab9ecf0bc7c4} nx OptIn bootmenupolicy Standard

Windows Boot Loader

identifier {default} device partition=D: path \Windows\system32\winload.efi description Windows 10 locale en-US inherit {bootloadersettings} recoverysequence {b582da04-8fb9-11ef-9705-ab9ecf0bc7c4} displaymessageoverride Recovery recoveryenabled Yes isolatedcontext Yes allowedinmemorysettings 0x15000075 osdevice partition=D: systemroot \Windows resumeobject {b582da02-8fb9-11ef-9705-ab9ecf0bc7c4} nx OptIn bootmenupolicy Standard

Changing the Boot Order in the UEFI Firmware

This was tested using Windows 11 (23H2 v2). A dual boot with Ubuntu was setup in a VirtualBox VM in order create an example to use in this answer. Windows 11 and Ubuntu were installed on different drives.

The command below lists all firmware applications stored in the UEFI and the current UEFI boot order.

bcdedit /enum firmware

Example output is shown below.


Firmware Boot Manager
---------------------
identifier              {fwbootmgr}
displayorder            {bootmgr}
                        {46e42764-9058-11ef-aca9-806e6f6e6963}
                        {46e42760-9058-11ef-aca9-806e6f6e6963}
                        {46e42761-9058-11ef-aca9-806e6f6e6963}
                        {46e42762-9058-11ef-aca9-806e6f6e6963}
                        {46e42763-9058-11ef-aca9-806e6f6e6963}
                        {46e4275f-9058-11ef-aca9-806e6f6e6963}
                        {b7cd826a-904c-11ef-acaf-806e6f6e6963}
timeout                 0

Windows Boot Manager

identifier {bootmgr} device partition=\Device\HarddiskVolume5 path \EFI\Microsoft\Boot\bootmgfw.efi description Windows Boot Manager locale en-us inherit {globalsettings} default {current} resumeobject {70ace0d4-9026-11ef-aca7-080027990617} displayorder {46e42764-9058-11ef-aca9-806e6f6e6963} {bootmgr} {46e42760-9058-11ef-aca9-806e6f6e6963} {46e42761-9058-11ef-aca9-806e6f6e6963} {46e42762-9058-11ef-aca9-806e6f6e6963} {46e42763-9058-11ef-aca9-806e6f6e6963} {46e4275f-9058-11ef-aca9-806e6f6e6963} {b7cd826a-904c-11ef-acaf-806e6f6e6963} toolsdisplayorder {memdiag} timeout 30

Firmware Application (101fffff)

identifier {46e4275f-9058-11ef-aca9-806e6f6e6963} description UiApp

Firmware Application (101fffff)

identifier {46e42760-9058-11ef-aca9-806e6f6e6963} description UEFI VBOX CD-ROM VB1-1a2b3c4d

Firmware Application (101fffff)

identifier {46e42761-9058-11ef-aca9-806e6f6e6963} description UEFI VBOX HARDDISK VBb8a01863-6eda7721

Firmware Application (101fffff)

identifier {46e42762-9058-11ef-aca9-806e6f6e6963} description EFI Internal Shell

Firmware Application (101fffff)

identifier {46e42763-9058-11ef-aca9-806e6f6e6963} description UEFI VBOX HARDDISK VBadc6be13-21cdb45c

Firmware Application (101fffff)

identifier {46e42764-9058-11ef-aca9-806e6f6e6963} device partition=\Device\HarddiskVolume1 path \EFI\ubuntu\shimx64.efi description ubuntu

Firmware Application (101fffff)

identifier {b7cd826a-904c-11ef-acaf-806e6f6e6963} description UEFI PXEv4 (MAC:080027990617)

You can compare the output from the previous command to what appears in the UEFI firmware settings shown in the image below.

The command to switch Windows with Ubuntu in the boot order is given below.

bcdedit /set {fwbootmgr} displayorder {46e42764-9058-11ef-aca9-806e6f6e6963} {bootmgr} {46e42760-9058-11ef-aca9-806e6f6e6963} {46e42761-9058-11ef-aca9-806e6f6e6963} {46e42762-9058-11ef-aca9-806e6f6e6963} {46e42763-9058-11ef-aca9-806e6f6e6963} {46e4275f-9058-11ef-aca9-806e6f6e6963} {b7cd826a-904c-11ef-acaf-806e6f6e6963}

The change can be confirmed by entering the command below.

bcdedit /enum {fwbootmgr}

Example output is shown below.


Firmware Boot Manager
---------------------
identifier              {fwbootmgr}
displayorder            {46e42764-9058-11ef-aca9-806e6f6e6963}
                        {bootmgr}
                        {46e42760-9058-11ef-aca9-806e6f6e6963}
                        {46e42761-9058-11ef-aca9-806e6f6e6963}
                        {46e42762-9058-11ef-aca9-806e6f6e6963}
                        {46e42763-9058-11ef-aca9-806e6f6e6963}
                        {46e4275f-9058-11ef-aca9-806e6f6e6963}
                        {b7cd826a-904c-11ef-acaf-806e6f6e6963}
timeout                 0

References