从 Windows 更改 UEFI 启动顺序

从 Windows 更改 UEFI 启动顺序

我无法让 Windows在 Windows 内部UEFI将启动顺序更改为PXE首先启动。我试图使系统自动化,以便PXE每次都能启动,这样我就可以控制启动选项。我尝试过bcdedit

bcdedit /set {fwbootmgr} DEFAULT <uuid of nic>

有类似efibootmgr适用于 Windows 的东西吗?

答案1

从 {fwbootmgr}/“显示顺序”(映射到 NVRAM 中的“启动顺序”)中删除网络加载器的 {GUID} 并将其重新添加为第一个,最终将改变 NVRAM 启动顺序。

NVRAM 中的启动顺序是一个整数列表,但 Windows 将其映射到 GUIDS 列表(最终与 {bootmgr} 的“显示顺序”保持类似)。

建议的解决方案尚未尝试,并且不保证有效。我假设 UEFI 在冷启动时重新扫描硬件,因此可启动设备列表已更新(并且从启动顺序中删除网络是安全的,因为它将在下次启动时重新出现)。

似乎 Windows 出于某种原因限制了用户对 NVRAM 的访问(可能与禁止在 UEFI 上链式加载 Linux/其他启动管理器/加载器的原因相同)。

在 BCD 中,{fwbootmgr} 仅映射了两个 NVRAM 变量 - “显示顺序”(启动顺序) 和“超时”。但您可以设置 bootnext 变量(在 BCD 中没有映射)。

你可以试试可视化 BCD 编辑器0.9.0.1 用于查看完整的 BCD 以及更改每个元素和 BCD 对象。

答案2

Dell 提供了名为 Dell Command Configure 的实用程序,它将帮助您从 Windows 配置所有客户端系统启动顺序,并在操作系统部署期间通过 SCCM 任务序列进行配置。

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

答案3

用于bcdedit /set {fwbootmgr} bootsequence {GUID}设置一次性启动。
https://github.com/chengxuncc/booToLinux

答案4

我还在上发布了基于 powershell/bcdedit 的答案如何阻止 Windows 10 安装修改 BIOS 启动设置?,以补充 aggieNick02 的 C++ 答案。它在这里:


我想出了一个对我有用的 powershell 脚本。它并不完美,因为它只是“愚蠢地”将第一个非 Windows 启动项移到顶部。这对我来说是可行的,也许有一种方法可以让它更智能,只是我没有找到。

它看起来很长,但主要是注释,并且格式化以便于理解。它可以重写为 5 或 6 行。

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

相关内容