Changing uEFI boot order from Windows The Next CEO of Stack OverflowHow do I stop Windows 10 Install from modifying BIOS boot settings?Useful Command-line Commands on WindowsChanging network boot order (pxe) using ipmitoolWDS 2012: UEFI Client Network Boot results in error 0x102SuperMicro X9SRE only boots UEFI Debian 8.1 when “forced”pxe boot uefi ends with pxe-e16: No offer received - ip helper address in placeForcing legacy bootUEFI iPXE boot into debian results in grub shellHow do I stop Windows 10 Install from modifying BIOS boot settings?Can PXE Boot in UEFI but not in LegacyTroubleshoot libvirt-managed qemu x86-64 UEFI guest

Is it professional to write unrelated content in an almost-empty email?

What happens if you roll doubles 3 times then land on "Go to jail?"

multiple labels for a single equation

Return the Closest Prime Number

Inappropriate reference requests from Journal reviewers

Won the lottery - how do I keep the money?

What happened in Rome, when the western empire "fell"?

What does "Its cash flow is deeply negative" mean?

How did the Bene Gesserit know how to make a Kwisatz Haderach?

How to make a variable always equal to the result of some calculations?

Why does standard notation not preserve intervals (visually)

Is HostGator storing my password in plaintext?

Sending manuscript to multiple publishers

Which tube will fit a -(700 x 25c) wheel?

Unreliable Magic - Is it worth it?

How to transpose the 1st and -1th levels of arbitrarily nested array?

How do we know the LHC results are robust?

Anatomically Correct Strange Women In Ponds Distributing Swords

Why am I allowed to create multiple unique pointers from a single object?

How does the mv command work with external drives?

What's the best way to handle refactoring a big file?

Novel about a guy who is possessed by the divine essence and the world ends?

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?

Complex fractions



Changing uEFI boot order from Windows



The Next CEO of Stack OverflowHow do I stop Windows 10 Install from modifying BIOS boot settings?Useful Command-line Commands on WindowsChanging network boot order (pxe) using ipmitoolWDS 2012: UEFI Client Network Boot results in error 0x102SuperMicro X9SRE only boots UEFI Debian 8.1 when “forced”pxe boot uefi ends with pxe-e16: No offer received - ip helper address in placeForcing legacy bootUEFI iPXE boot into debian results in grub shellHow do I stop Windows 10 Install from modifying BIOS boot settings?Can PXE Boot in UEFI but not in LegacyTroubleshoot libvirt-managed qemu x86-64 UEFI guest










3















I can't get Windows to change the uEFI boot order to PXE boot first from within windows. I'm trying to automate the system so that it PXE boots every time, so I can control the boot option. I've tried BCDEdit:



bcdedit /set fwbootmgr DEFAULT <uuid of nic>


Is there anything like efibootmgr for windows?










share|improve this question






















  • I don't think it is possible to access uEFI from within Windows, but I don;t have any hard evidence for that. bcdedit changes the boot store on a boot device, but you want to change which boot device is used.

    – Peter Hahndorf
    Aug 15 '15 at 12:24











  • I don't understand why windows wouldn't have access to the uEFI nvRAM. Linux kernels pretty much universally support modifying this via efibootmgr. There's a program called "EasyUEFI" which provides this support but it costs money for command line/server support.

    – Collin Reynolds
    Aug 15 '15 at 18:41















3















I can't get Windows to change the uEFI boot order to PXE boot first from within windows. I'm trying to automate the system so that it PXE boots every time, so I can control the boot option. I've tried BCDEdit:



bcdedit /set fwbootmgr DEFAULT <uuid of nic>


Is there anything like efibootmgr for windows?










share|improve this question






















  • I don't think it is possible to access uEFI from within Windows, but I don;t have any hard evidence for that. bcdedit changes the boot store on a boot device, but you want to change which boot device is used.

    – Peter Hahndorf
    Aug 15 '15 at 12:24











  • I don't understand why windows wouldn't have access to the uEFI nvRAM. Linux kernels pretty much universally support modifying this via efibootmgr. There's a program called "EasyUEFI" which provides this support but it costs money for command line/server support.

    – Collin Reynolds
    Aug 15 '15 at 18:41













3












3








3








I can't get Windows to change the uEFI boot order to PXE boot first from within windows. I'm trying to automate the system so that it PXE boots every time, so I can control the boot option. I've tried BCDEdit:



bcdedit /set fwbootmgr DEFAULT <uuid of nic>


Is there anything like efibootmgr for windows?










share|improve this question














I can't get Windows to change the uEFI boot order to PXE boot first from within windows. I'm trying to automate the system so that it PXE boots every time, so I can control the boot option. I've tried BCDEdit:



bcdedit /set fwbootmgr DEFAULT <uuid of nic>


Is there anything like efibootmgr for windows?







windows pxe-boot uefi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 14 '15 at 23:19









Collin ReynoldsCollin Reynolds

1612




1612












  • I don't think it is possible to access uEFI from within Windows, but I don;t have any hard evidence for that. bcdedit changes the boot store on a boot device, but you want to change which boot device is used.

    – Peter Hahndorf
    Aug 15 '15 at 12:24











  • I don't understand why windows wouldn't have access to the uEFI nvRAM. Linux kernels pretty much universally support modifying this via efibootmgr. There's a program called "EasyUEFI" which provides this support but it costs money for command line/server support.

    – Collin Reynolds
    Aug 15 '15 at 18:41

















  • I don't think it is possible to access uEFI from within Windows, but I don;t have any hard evidence for that. bcdedit changes the boot store on a boot device, but you want to change which boot device is used.

    – Peter Hahndorf
    Aug 15 '15 at 12:24











  • I don't understand why windows wouldn't have access to the uEFI nvRAM. Linux kernels pretty much universally support modifying this via efibootmgr. There's a program called "EasyUEFI" which provides this support but it costs money for command line/server support.

    – Collin Reynolds
    Aug 15 '15 at 18:41
















I don't think it is possible to access uEFI from within Windows, but I don;t have any hard evidence for that. bcdedit changes the boot store on a boot device, but you want to change which boot device is used.

– Peter Hahndorf
Aug 15 '15 at 12:24





I don't think it is possible to access uEFI from within Windows, but I don;t have any hard evidence for that. bcdedit changes the boot store on a boot device, but you want to change which boot device is used.

– Peter Hahndorf
Aug 15 '15 at 12:24













I don't understand why windows wouldn't have access to the uEFI nvRAM. Linux kernels pretty much universally support modifying this via efibootmgr. There's a program called "EasyUEFI" which provides this support but it costs money for command line/server support.

– Collin Reynolds
Aug 15 '15 at 18:41





I don't understand why windows wouldn't have access to the uEFI nvRAM. Linux kernels pretty much universally support modifying this via efibootmgr. There's a program called "EasyUEFI" which provides this support but it costs money for command line/server support.

– Collin Reynolds
Aug 15 '15 at 18:41










4 Answers
4






active

oldest

votes


















2














Dell Provides utility called Dell Command Configure which will help you to configure all client systems boot order from windows and during OS deployment through SCCM task sequence.



http://en.community.dell.com/techcenter/enterprise-client/w/wiki/7532.dell-command-configure






share|improve this answer






























    1














    Deleting GUID of loader for Network from fwbootmgr/"display order" (mapped to "boot order" in NVRAM) and re-adding it as first eventually will change NVRAM boot order.



    Boot order in NVRAM is a list of integers but Windows maps it to a list of GUIDS (eventually to maintain analogy with "display order" for bootmgr).



    Proposed solution not tried and not guarantied to work. I assume that UEFI rescans hardware on cold boot so the list of bootable devices is updated (and deletion of Network from boot order is safe as it will reappear on next boot).



    It seems Windows is limiting access to NVRAM for users for some reason (maybe the same reason used for forbidding chain loading Linux/other boot manager/loader on UEFI).



    In BCD there are only two mapped NVRAM variables for fwbootmgr - "display order"(boot order) and "timeout". But you can set bootnext variable (which has no mapping in BCD).



    You can try Visual BCD Editor 0.9.0.1 for viewing complete BCD as well as changing every element and BCD object.






    share|improve this answer






























      0














      I just posted an answer to this over at another serverfault question: How do I stop Windows 10 Install from modifying BIOS boot settings?



      Guessing we might want to close this question as a duplicate of that one since that one has a working answer (apologies for not finding this question first).






      share|improve this answer
































        0














        I also posted a powershell/bcdedit-based answer over at How do I stop Windows 10 Install from modifying BIOS boot settings?, to supplement aggieNick02's C++ answer. Here it is:




        I came up with this powershell script that works for me. It's not perfect because it just "stupidly" moves the first non-Windows boot entry to the top. That works for my purposes and there may be a way to make it smarter that I just didn't find.



        It looks long, but it's mostly comments and formatted for comprehension. It could be re-written to 5 or 6 lines.



        https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order



        # This script looks for the first non-Windows Boot Manager entry in the UEFI/GPT boot order and moves it to the top
        # For preventing newly installed Windows from hijacking the top boot order spot on my UEFI/GPT image testing VMs
        # by mmseng
        # https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order

        # Notes:
        # - There's very little point in using this on regular production machines being deployed. Its main use is for machines being repeatedly imaged, or might be useful for lab machines.
        # - AFAICT bcdedit provideds no way to pull the friendly names of the devices in the overall UEFI boot order list. Therefore, this script only moves the first entry it identifies in the list which is NOT "bootmgr" (a.k.a. "Windows Boot Manager"). It's up to the user to make sure the boot order will exist in a state where the desired result is achieved.
        # - In my case, my test UEFI VMs initially have the boot order of 1) "EFI Network", 2) whatever else. When Windows is installed with GPT partitioning, it changes the boot order to 1) "Windows Boot Manager", 2) "EFI Network", 3) whatever else. In that state, this script can be used to change the boot order to 1) "EFI Network", 2) "Windows Boot Manager", 3) whatever else.
        # - This functionality relies on the completely undocumented feature of bcdedit to modify the "fwbootmgr" GPT entry, which contains the overall list of UEFI boot devices.
        # - AFAICT bcdedit is really only designed to edit Windows' own "bootmgr" entry which represents one of the "boot devices" in the overall UEFI list.
        # - Here are some sources:
        # - https://www.cnet.com/forums/discussions/bugged-bcdedit-349276/
        # - https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/bcd-system-store-settings-for-uefi
        # - https://www.boyans.net/DownloadVisualBCD.html
        # - https://serverfault.com/questions/813695/how-do-i-stop-windows-10-install-from-modifying-bios-boot-settings
        # - https://serverfault.com/questions/714337/changing-uefi-boot-order-from-windows


        # Read current boot order
        echo "Reading current boot order..."
        $bcdOutput = cmd /c bcdedit /enum "fwbootmgr"
        echo $bcdOutput

        # Kill as many of the stupid characters as possible
        echo "Removing extraneous characters from boot order output..."
        $bcdOutput = $bcdOutput -replace 's+',''
        $bcdOutput = $bcdOutput -replace '`t',''
        $bcdOutput = $bcdOutput -replace '`n',''
        $bcdOutput = $bcdOutput -replace '`r',''
        $bcdOutput = $bcdOutput.trim()
        $bcdOutput = $bcdOutput.trimEnd()
        $bcdOutput = $bcdOutput.trimStart()
        $bcdOutput = $bcdOutput -replace ' ',''
        echo $bcdOutput

        # Define a reliable regex to capture the UUIDs of non-Windows Boot Manager devices in the boot order list
        # This is difficult because apparently Powershell interprets regex is a fairly non-standard way (.NET regex flavor)
        # https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions
        # Even then, .NET regex testers I used didn't match the behavior of what I got out of various Powershell commands that accept regex strings
        # However this seems to work, even though I can't replicate the results in any regex testers
        $regex = [regex]'^([-a-z0-9]+)+'
        echo "Defined regex as: $regex"

        # Save matches
        echo "Save strings matching regex..."
        $foundMatches = $bcdOutput -match $regex

        # Grab first match
        # If Windows Boot Manager (a.k.a. "bootmgr" was the first in the list, this should be the second
        # Which means it was probably the first before Windows hijacked the first spot
        # Which means it was probably my "EFI Network" boot device
        $secondBootEntry = $foundMatches[0]
        echo "First match: $secondBootEntry"

        # Move it to the first spot
        echo "Running this command:"
        echo "cmd /c bcdedit $bcdParams /set `"fwbootmgr`" displayorder $secondBootEntry /addfirst"
        cmd /c bcdedit $bcdParams /set "fwbootmgr" displayorder $secondBootEntry /addfirst





        share|improve this answer








        New contributor




        mmseng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




















          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "2"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f714337%2fchanging-uefi-boot-order-from-windows%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Dell Provides utility called Dell Command Configure which will help you to configure all client systems boot order from windows and during OS deployment through SCCM task sequence.



          http://en.community.dell.com/techcenter/enterprise-client/w/wiki/7532.dell-command-configure






          share|improve this answer



























            2














            Dell Provides utility called Dell Command Configure which will help you to configure all client systems boot order from windows and during OS deployment through SCCM task sequence.



            http://en.community.dell.com/techcenter/enterprise-client/w/wiki/7532.dell-command-configure






            share|improve this answer

























              2












              2








              2







              Dell Provides utility called Dell Command Configure which will help you to configure all client systems boot order from windows and during OS deployment through SCCM task sequence.



              http://en.community.dell.com/techcenter/enterprise-client/w/wiki/7532.dell-command-configure






              share|improve this answer













              Dell Provides utility called Dell Command Configure which will help you to configure all client systems boot order from windows and during OS deployment through SCCM task sequence.



              http://en.community.dell.com/techcenter/enterprise-client/w/wiki/7532.dell-command-configure







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jan 20 '18 at 13:40









              Pr ModPr Mod

              236




              236























                  1














                  Deleting GUID of loader for Network from fwbootmgr/"display order" (mapped to "boot order" in NVRAM) and re-adding it as first eventually will change NVRAM boot order.



                  Boot order in NVRAM is a list of integers but Windows maps it to a list of GUIDS (eventually to maintain analogy with "display order" for bootmgr).



                  Proposed solution not tried and not guarantied to work. I assume that UEFI rescans hardware on cold boot so the list of bootable devices is updated (and deletion of Network from boot order is safe as it will reappear on next boot).



                  It seems Windows is limiting access to NVRAM for users for some reason (maybe the same reason used for forbidding chain loading Linux/other boot manager/loader on UEFI).



                  In BCD there are only two mapped NVRAM variables for fwbootmgr - "display order"(boot order) and "timeout". But you can set bootnext variable (which has no mapping in BCD).



                  You can try Visual BCD Editor 0.9.0.1 for viewing complete BCD as well as changing every element and BCD object.






                  share|improve this answer



























                    1














                    Deleting GUID of loader for Network from fwbootmgr/"display order" (mapped to "boot order" in NVRAM) and re-adding it as first eventually will change NVRAM boot order.



                    Boot order in NVRAM is a list of integers but Windows maps it to a list of GUIDS (eventually to maintain analogy with "display order" for bootmgr).



                    Proposed solution not tried and not guarantied to work. I assume that UEFI rescans hardware on cold boot so the list of bootable devices is updated (and deletion of Network from boot order is safe as it will reappear on next boot).



                    It seems Windows is limiting access to NVRAM for users for some reason (maybe the same reason used for forbidding chain loading Linux/other boot manager/loader on UEFI).



                    In BCD there are only two mapped NVRAM variables for fwbootmgr - "display order"(boot order) and "timeout". But you can set bootnext variable (which has no mapping in BCD).



                    You can try Visual BCD Editor 0.9.0.1 for viewing complete BCD as well as changing every element and BCD object.






                    share|improve this answer

























                      1












                      1








                      1







                      Deleting GUID of loader for Network from fwbootmgr/"display order" (mapped to "boot order" in NVRAM) and re-adding it as first eventually will change NVRAM boot order.



                      Boot order in NVRAM is a list of integers but Windows maps it to a list of GUIDS (eventually to maintain analogy with "display order" for bootmgr).



                      Proposed solution not tried and not guarantied to work. I assume that UEFI rescans hardware on cold boot so the list of bootable devices is updated (and deletion of Network from boot order is safe as it will reappear on next boot).



                      It seems Windows is limiting access to NVRAM for users for some reason (maybe the same reason used for forbidding chain loading Linux/other boot manager/loader on UEFI).



                      In BCD there are only two mapped NVRAM variables for fwbootmgr - "display order"(boot order) and "timeout". But you can set bootnext variable (which has no mapping in BCD).



                      You can try Visual BCD Editor 0.9.0.1 for viewing complete BCD as well as changing every element and BCD object.






                      share|improve this answer













                      Deleting GUID of loader for Network from fwbootmgr/"display order" (mapped to "boot order" in NVRAM) and re-adding it as first eventually will change NVRAM boot order.



                      Boot order in NVRAM is a list of integers but Windows maps it to a list of GUIDS (eventually to maintain analogy with "display order" for bootmgr).



                      Proposed solution not tried and not guarantied to work. I assume that UEFI rescans hardware on cold boot so the list of bootable devices is updated (and deletion of Network from boot order is safe as it will reappear on next boot).



                      It seems Windows is limiting access to NVRAM for users for some reason (maybe the same reason used for forbidding chain loading Linux/other boot manager/loader on UEFI).



                      In BCD there are only two mapped NVRAM variables for fwbootmgr - "display order"(boot order) and "timeout". But you can set bootnext variable (which has no mapping in BCD).



                      You can try Visual BCD Editor 0.9.0.1 for viewing complete BCD as well as changing every element and BCD object.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jan 13 '16 at 22:41









                      snayobsnayob

                      1514




                      1514





















                          0














                          I just posted an answer to this over at another serverfault question: How do I stop Windows 10 Install from modifying BIOS boot settings?



                          Guessing we might want to close this question as a duplicate of that one since that one has a working answer (apologies for not finding this question first).






                          share|improve this answer





























                            0














                            I just posted an answer to this over at another serverfault question: How do I stop Windows 10 Install from modifying BIOS boot settings?



                            Guessing we might want to close this question as a duplicate of that one since that one has a working answer (apologies for not finding this question first).






                            share|improve this answer



























                              0












                              0








                              0







                              I just posted an answer to this over at another serverfault question: How do I stop Windows 10 Install from modifying BIOS boot settings?



                              Guessing we might want to close this question as a duplicate of that one since that one has a working answer (apologies for not finding this question first).






                              share|improve this answer















                              I just posted an answer to this over at another serverfault question: How do I stop Windows 10 Install from modifying BIOS boot settings?



                              Guessing we might want to close this question as a duplicate of that one since that one has a working answer (apologies for not finding this question first).







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Apr 13 '17 at 12:14









                              Community

                              1




                              1










                              answered Nov 9 '16 at 22:42









                              aggieNick02aggieNick02

                              14119




                              14119





















                                  0














                                  I also posted a powershell/bcdedit-based answer over at How do I stop Windows 10 Install from modifying BIOS boot settings?, to supplement aggieNick02's C++ answer. Here it is:




                                  I came up with this powershell script that works for me. It's not perfect because it just "stupidly" moves the first non-Windows boot entry to the top. That works for my purposes and there may be a way to make it smarter that I just didn't find.



                                  It looks long, but it's mostly comments and formatted for comprehension. It could be re-written to 5 or 6 lines.



                                  https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order



                                  # This script looks for the first non-Windows Boot Manager entry in the UEFI/GPT boot order and moves it to the top
                                  # For preventing newly installed Windows from hijacking the top boot order spot on my UEFI/GPT image testing VMs
                                  # by mmseng
                                  # https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order

                                  # Notes:
                                  # - There's very little point in using this on regular production machines being deployed. Its main use is for machines being repeatedly imaged, or might be useful for lab machines.
                                  # - AFAICT bcdedit provideds no way to pull the friendly names of the devices in the overall UEFI boot order list. Therefore, this script only moves the first entry it identifies in the list which is NOT "bootmgr" (a.k.a. "Windows Boot Manager"). It's up to the user to make sure the boot order will exist in a state where the desired result is achieved.
                                  # - In my case, my test UEFI VMs initially have the boot order of 1) "EFI Network", 2) whatever else. When Windows is installed with GPT partitioning, it changes the boot order to 1) "Windows Boot Manager", 2) "EFI Network", 3) whatever else. In that state, this script can be used to change the boot order to 1) "EFI Network", 2) "Windows Boot Manager", 3) whatever else.
                                  # - This functionality relies on the completely undocumented feature of bcdedit to modify the "fwbootmgr" GPT entry, which contains the overall list of UEFI boot devices.
                                  # - AFAICT bcdedit is really only designed to edit Windows' own "bootmgr" entry which represents one of the "boot devices" in the overall UEFI list.
                                  # - Here are some sources:
                                  # - https://www.cnet.com/forums/discussions/bugged-bcdedit-349276/
                                  # - https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/bcd-system-store-settings-for-uefi
                                  # - https://www.boyans.net/DownloadVisualBCD.html
                                  # - https://serverfault.com/questions/813695/how-do-i-stop-windows-10-install-from-modifying-bios-boot-settings
                                  # - https://serverfault.com/questions/714337/changing-uefi-boot-order-from-windows


                                  # Read current boot order
                                  echo "Reading current boot order..."
                                  $bcdOutput = cmd /c bcdedit /enum "fwbootmgr"
                                  echo $bcdOutput

                                  # Kill as many of the stupid characters as possible
                                  echo "Removing extraneous characters from boot order output..."
                                  $bcdOutput = $bcdOutput -replace 's+',''
                                  $bcdOutput = $bcdOutput -replace '`t',''
                                  $bcdOutput = $bcdOutput -replace '`n',''
                                  $bcdOutput = $bcdOutput -replace '`r',''
                                  $bcdOutput = $bcdOutput.trim()
                                  $bcdOutput = $bcdOutput.trimEnd()
                                  $bcdOutput = $bcdOutput.trimStart()
                                  $bcdOutput = $bcdOutput -replace ' ',''
                                  echo $bcdOutput

                                  # Define a reliable regex to capture the UUIDs of non-Windows Boot Manager devices in the boot order list
                                  # This is difficult because apparently Powershell interprets regex is a fairly non-standard way (.NET regex flavor)
                                  # https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions
                                  # Even then, .NET regex testers I used didn't match the behavior of what I got out of various Powershell commands that accept regex strings
                                  # However this seems to work, even though I can't replicate the results in any regex testers
                                  $regex = [regex]'^([-a-z0-9]+)+'
                                  echo "Defined regex as: $regex"

                                  # Save matches
                                  echo "Save strings matching regex..."
                                  $foundMatches = $bcdOutput -match $regex

                                  # Grab first match
                                  # If Windows Boot Manager (a.k.a. "bootmgr" was the first in the list, this should be the second
                                  # Which means it was probably the first before Windows hijacked the first spot
                                  # Which means it was probably my "EFI Network" boot device
                                  $secondBootEntry = $foundMatches[0]
                                  echo "First match: $secondBootEntry"

                                  # Move it to the first spot
                                  echo "Running this command:"
                                  echo "cmd /c bcdedit $bcdParams /set `"fwbootmgr`" displayorder $secondBootEntry /addfirst"
                                  cmd /c bcdedit $bcdParams /set "fwbootmgr" displayorder $secondBootEntry /addfirst





                                  share|improve this answer








                                  New contributor




                                  mmseng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.
























                                    0














                                    I also posted a powershell/bcdedit-based answer over at How do I stop Windows 10 Install from modifying BIOS boot settings?, to supplement aggieNick02's C++ answer. Here it is:




                                    I came up with this powershell script that works for me. It's not perfect because it just "stupidly" moves the first non-Windows boot entry to the top. That works for my purposes and there may be a way to make it smarter that I just didn't find.



                                    It looks long, but it's mostly comments and formatted for comprehension. It could be re-written to 5 or 6 lines.



                                    https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order



                                    # This script looks for the first non-Windows Boot Manager entry in the UEFI/GPT boot order and moves it to the top
                                    # For preventing newly installed Windows from hijacking the top boot order spot on my UEFI/GPT image testing VMs
                                    # by mmseng
                                    # https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order

                                    # Notes:
                                    # - There's very little point in using this on regular production machines being deployed. Its main use is for machines being repeatedly imaged, or might be useful for lab machines.
                                    # - AFAICT bcdedit provideds no way to pull the friendly names of the devices in the overall UEFI boot order list. Therefore, this script only moves the first entry it identifies in the list which is NOT "bootmgr" (a.k.a. "Windows Boot Manager"). It's up to the user to make sure the boot order will exist in a state where the desired result is achieved.
                                    # - In my case, my test UEFI VMs initially have the boot order of 1) "EFI Network", 2) whatever else. When Windows is installed with GPT partitioning, it changes the boot order to 1) "Windows Boot Manager", 2) "EFI Network", 3) whatever else. In that state, this script can be used to change the boot order to 1) "EFI Network", 2) "Windows Boot Manager", 3) whatever else.
                                    # - This functionality relies on the completely undocumented feature of bcdedit to modify the "fwbootmgr" GPT entry, which contains the overall list of UEFI boot devices.
                                    # - AFAICT bcdedit is really only designed to edit Windows' own "bootmgr" entry which represents one of the "boot devices" in the overall UEFI list.
                                    # - Here are some sources:
                                    # - https://www.cnet.com/forums/discussions/bugged-bcdedit-349276/
                                    # - https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/bcd-system-store-settings-for-uefi
                                    # - https://www.boyans.net/DownloadVisualBCD.html
                                    # - https://serverfault.com/questions/813695/how-do-i-stop-windows-10-install-from-modifying-bios-boot-settings
                                    # - https://serverfault.com/questions/714337/changing-uefi-boot-order-from-windows


                                    # Read current boot order
                                    echo "Reading current boot order..."
                                    $bcdOutput = cmd /c bcdedit /enum "fwbootmgr"
                                    echo $bcdOutput

                                    # Kill as many of the stupid characters as possible
                                    echo "Removing extraneous characters from boot order output..."
                                    $bcdOutput = $bcdOutput -replace 's+',''
                                    $bcdOutput = $bcdOutput -replace '`t',''
                                    $bcdOutput = $bcdOutput -replace '`n',''
                                    $bcdOutput = $bcdOutput -replace '`r',''
                                    $bcdOutput = $bcdOutput.trim()
                                    $bcdOutput = $bcdOutput.trimEnd()
                                    $bcdOutput = $bcdOutput.trimStart()
                                    $bcdOutput = $bcdOutput -replace ' ',''
                                    echo $bcdOutput

                                    # Define a reliable regex to capture the UUIDs of non-Windows Boot Manager devices in the boot order list
                                    # This is difficult because apparently Powershell interprets regex is a fairly non-standard way (.NET regex flavor)
                                    # https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions
                                    # Even then, .NET regex testers I used didn't match the behavior of what I got out of various Powershell commands that accept regex strings
                                    # However this seems to work, even though I can't replicate the results in any regex testers
                                    $regex = [regex]'^([-a-z0-9]+)+'
                                    echo "Defined regex as: $regex"

                                    # Save matches
                                    echo "Save strings matching regex..."
                                    $foundMatches = $bcdOutput -match $regex

                                    # Grab first match
                                    # If Windows Boot Manager (a.k.a. "bootmgr" was the first in the list, this should be the second
                                    # Which means it was probably the first before Windows hijacked the first spot
                                    # Which means it was probably my "EFI Network" boot device
                                    $secondBootEntry = $foundMatches[0]
                                    echo "First match: $secondBootEntry"

                                    # Move it to the first spot
                                    echo "Running this command:"
                                    echo "cmd /c bcdedit $bcdParams /set `"fwbootmgr`" displayorder $secondBootEntry /addfirst"
                                    cmd /c bcdedit $bcdParams /set "fwbootmgr" displayorder $secondBootEntry /addfirst





                                    share|improve this answer








                                    New contributor




                                    mmseng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.






















                                      0












                                      0








                                      0







                                      I also posted a powershell/bcdedit-based answer over at How do I stop Windows 10 Install from modifying BIOS boot settings?, to supplement aggieNick02's C++ answer. Here it is:




                                      I came up with this powershell script that works for me. It's not perfect because it just "stupidly" moves the first non-Windows boot entry to the top. That works for my purposes and there may be a way to make it smarter that I just didn't find.



                                      It looks long, but it's mostly comments and formatted for comprehension. It could be re-written to 5 or 6 lines.



                                      https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order



                                      # This script looks for the first non-Windows Boot Manager entry in the UEFI/GPT boot order and moves it to the top
                                      # For preventing newly installed Windows from hijacking the top boot order spot on my UEFI/GPT image testing VMs
                                      # by mmseng
                                      # https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order

                                      # Notes:
                                      # - There's very little point in using this on regular production machines being deployed. Its main use is for machines being repeatedly imaged, or might be useful for lab machines.
                                      # - AFAICT bcdedit provideds no way to pull the friendly names of the devices in the overall UEFI boot order list. Therefore, this script only moves the first entry it identifies in the list which is NOT "bootmgr" (a.k.a. "Windows Boot Manager"). It's up to the user to make sure the boot order will exist in a state where the desired result is achieved.
                                      # - In my case, my test UEFI VMs initially have the boot order of 1) "EFI Network", 2) whatever else. When Windows is installed with GPT partitioning, it changes the boot order to 1) "Windows Boot Manager", 2) "EFI Network", 3) whatever else. In that state, this script can be used to change the boot order to 1) "EFI Network", 2) "Windows Boot Manager", 3) whatever else.
                                      # - This functionality relies on the completely undocumented feature of bcdedit to modify the "fwbootmgr" GPT entry, which contains the overall list of UEFI boot devices.
                                      # - AFAICT bcdedit is really only designed to edit Windows' own "bootmgr" entry which represents one of the "boot devices" in the overall UEFI list.
                                      # - Here are some sources:
                                      # - https://www.cnet.com/forums/discussions/bugged-bcdedit-349276/
                                      # - https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/bcd-system-store-settings-for-uefi
                                      # - https://www.boyans.net/DownloadVisualBCD.html
                                      # - https://serverfault.com/questions/813695/how-do-i-stop-windows-10-install-from-modifying-bios-boot-settings
                                      # - https://serverfault.com/questions/714337/changing-uefi-boot-order-from-windows


                                      # Read current boot order
                                      echo "Reading current boot order..."
                                      $bcdOutput = cmd /c bcdedit /enum "fwbootmgr"
                                      echo $bcdOutput

                                      # Kill as many of the stupid characters as possible
                                      echo "Removing extraneous characters from boot order output..."
                                      $bcdOutput = $bcdOutput -replace 's+',''
                                      $bcdOutput = $bcdOutput -replace '`t',''
                                      $bcdOutput = $bcdOutput -replace '`n',''
                                      $bcdOutput = $bcdOutput -replace '`r',''
                                      $bcdOutput = $bcdOutput.trim()
                                      $bcdOutput = $bcdOutput.trimEnd()
                                      $bcdOutput = $bcdOutput.trimStart()
                                      $bcdOutput = $bcdOutput -replace ' ',''
                                      echo $bcdOutput

                                      # Define a reliable regex to capture the UUIDs of non-Windows Boot Manager devices in the boot order list
                                      # This is difficult because apparently Powershell interprets regex is a fairly non-standard way (.NET regex flavor)
                                      # https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions
                                      # Even then, .NET regex testers I used didn't match the behavior of what I got out of various Powershell commands that accept regex strings
                                      # However this seems to work, even though I can't replicate the results in any regex testers
                                      $regex = [regex]'^([-a-z0-9]+)+'
                                      echo "Defined regex as: $regex"

                                      # Save matches
                                      echo "Save strings matching regex..."
                                      $foundMatches = $bcdOutput -match $regex

                                      # Grab first match
                                      # If Windows Boot Manager (a.k.a. "bootmgr" was the first in the list, this should be the second
                                      # Which means it was probably the first before Windows hijacked the first spot
                                      # Which means it was probably my "EFI Network" boot device
                                      $secondBootEntry = $foundMatches[0]
                                      echo "First match: $secondBootEntry"

                                      # Move it to the first spot
                                      echo "Running this command:"
                                      echo "cmd /c bcdedit $bcdParams /set `"fwbootmgr`" displayorder $secondBootEntry /addfirst"
                                      cmd /c bcdedit $bcdParams /set "fwbootmgr" displayorder $secondBootEntry /addfirst





                                      share|improve this answer








                                      New contributor




                                      mmseng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.










                                      I also posted a powershell/bcdedit-based answer over at How do I stop Windows 10 Install from modifying BIOS boot settings?, to supplement aggieNick02's C++ answer. Here it is:




                                      I came up with this powershell script that works for me. It's not perfect because it just "stupidly" moves the first non-Windows boot entry to the top. That works for my purposes and there may be a way to make it smarter that I just didn't find.



                                      It looks long, but it's mostly comments and formatted for comprehension. It could be re-written to 5 or 6 lines.



                                      https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order



                                      # This script looks for the first non-Windows Boot Manager entry in the UEFI/GPT boot order and moves it to the top
                                      # For preventing newly installed Windows from hijacking the top boot order spot on my UEFI/GPT image testing VMs
                                      # by mmseng
                                      # https://github.com/mmseng/bcdedit-revert-uefi-gpt-boot-order

                                      # Notes:
                                      # - There's very little point in using this on regular production machines being deployed. Its main use is for machines being repeatedly imaged, or might be useful for lab machines.
                                      # - AFAICT bcdedit provideds no way to pull the friendly names of the devices in the overall UEFI boot order list. Therefore, this script only moves the first entry it identifies in the list which is NOT "bootmgr" (a.k.a. "Windows Boot Manager"). It's up to the user to make sure the boot order will exist in a state where the desired result is achieved.
                                      # - In my case, my test UEFI VMs initially have the boot order of 1) "EFI Network", 2) whatever else. When Windows is installed with GPT partitioning, it changes the boot order to 1) "Windows Boot Manager", 2) "EFI Network", 3) whatever else. In that state, this script can be used to change the boot order to 1) "EFI Network", 2) "Windows Boot Manager", 3) whatever else.
                                      # - This functionality relies on the completely undocumented feature of bcdedit to modify the "fwbootmgr" GPT entry, which contains the overall list of UEFI boot devices.
                                      # - AFAICT bcdedit is really only designed to edit Windows' own "bootmgr" entry which represents one of the "boot devices" in the overall UEFI list.
                                      # - Here are some sources:
                                      # - https://www.cnet.com/forums/discussions/bugged-bcdedit-349276/
                                      # - https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/bcd-system-store-settings-for-uefi
                                      # - https://www.boyans.net/DownloadVisualBCD.html
                                      # - https://serverfault.com/questions/813695/how-do-i-stop-windows-10-install-from-modifying-bios-boot-settings
                                      # - https://serverfault.com/questions/714337/changing-uefi-boot-order-from-windows


                                      # Read current boot order
                                      echo "Reading current boot order..."
                                      $bcdOutput = cmd /c bcdedit /enum "fwbootmgr"
                                      echo $bcdOutput

                                      # Kill as many of the stupid characters as possible
                                      echo "Removing extraneous characters from boot order output..."
                                      $bcdOutput = $bcdOutput -replace 's+',''
                                      $bcdOutput = $bcdOutput -replace '`t',''
                                      $bcdOutput = $bcdOutput -replace '`n',''
                                      $bcdOutput = $bcdOutput -replace '`r',''
                                      $bcdOutput = $bcdOutput.trim()
                                      $bcdOutput = $bcdOutput.trimEnd()
                                      $bcdOutput = $bcdOutput.trimStart()
                                      $bcdOutput = $bcdOutput -replace ' ',''
                                      echo $bcdOutput

                                      # Define a reliable regex to capture the UUIDs of non-Windows Boot Manager devices in the boot order list
                                      # This is difficult because apparently Powershell interprets regex is a fairly non-standard way (.NET regex flavor)
                                      # https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions
                                      # Even then, .NET regex testers I used didn't match the behavior of what I got out of various Powershell commands that accept regex strings
                                      # However this seems to work, even though I can't replicate the results in any regex testers
                                      $regex = [regex]'^([-a-z0-9]+)+'
                                      echo "Defined regex as: $regex"

                                      # Save matches
                                      echo "Save strings matching regex..."
                                      $foundMatches = $bcdOutput -match $regex

                                      # Grab first match
                                      # If Windows Boot Manager (a.k.a. "bootmgr" was the first in the list, this should be the second
                                      # Which means it was probably the first before Windows hijacked the first spot
                                      # Which means it was probably my "EFI Network" boot device
                                      $secondBootEntry = $foundMatches[0]
                                      echo "First match: $secondBootEntry"

                                      # Move it to the first spot
                                      echo "Running this command:"
                                      echo "cmd /c bcdedit $bcdParams /set `"fwbootmgr`" displayorder $secondBootEntry /addfirst"
                                      cmd /c bcdedit $bcdParams /set "fwbootmgr" displayorder $secondBootEntry /addfirst






                                      share|improve this answer








                                      New contributor




                                      mmseng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.









                                      share|improve this answer



                                      share|improve this answer






                                      New contributor




                                      mmseng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.









                                      answered yesterday









                                      mmsengmmseng

                                      112




                                      112




                                      New contributor




                                      mmseng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.





                                      New contributor





                                      mmseng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.






                                      mmseng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.



























                                          draft saved

                                          draft discarded
















































                                          Thanks for contributing an answer to Server Fault!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid


                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.

                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f714337%2fchanging-uefi-boot-order-from-windows%23new-answer', 'question_page');

                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

                                          What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

                                          Why did Thanos need his ship to help him in the battle scene?Which actor plays Thanos in the Avengers mid-credits scene?Are there economic implications portrayed in comics where the buildings and cities are ruined almost daily?Old X-Men comic where team travels to alien world with a ring-like sun that needs recharging?Why does Ego need help sleeping?Is there an objective answer to who “the strongest Avenger” is?How did Banner get unstuck?Why did Thanos get hit?How did Thanos (or anyone) know the Infinity Stones would give him this power?Did Thanos leave Eitri alive for his after-sales service?In Avengers 1, why does Thanos need Loki?