powershell - winpe 的 BCD 条目仅启动准备自动修复

标签 powershell winpe bcdedit

我正在尝试将计算机重新启动到包含 Windows PE 的闪存驱动器介质中,但每次它只启动准备自动修复。这是我生成新 bcd 条目的 powershell:

$drive = (get-location).Drive.Name + ":"

$output = bcdedit /copy '{current}' /d "automaticabd"

$variable = "{" + $output.Split('{')[-1]
$variable = $variable.TrimEnd('.')

"Attaching $variable to device partition $drive"
bcdedit /set $variable device partition=$drive
""
"Attaching $variable to osdevice partition $drive"
bcdedit /set $variable osdevice partition=$drive
""
"Setting $variable path to EFI: \EFI\Boot\bootx64.efi"
bcdedit /set $variable path \EFI\Boot\bootx64.efi

""
"Other settings..."
bcdedit /set $variable systemroot \windows
bcdedit /set $variable winpe yes
bcdedit /set $variable  recoveryenabled No

bcdedit /bootsequence $variable
所有操作均已成功完成,就我所知,该条目似乎是正确的:
enter image description here
但是,当我重新启动计算机时,我曾经收到消息“正在修复自动恢复”,然后最终会进入 Windows 恢复环境。我已经添加了 bcdedit /set $variable recoveryenabled No ,这使得它不可能进入恢复环境,但我现在得到一个不同的错误:

The application or operating system couldn't be loaded because a required file is missing or contains errors.

File: \EFI\Boot\bootx64.efi Error code: 0xc000007b


但是,如果我进入启动选项并手动选择此文件,它会很好地启动到 winpe。
我不确定出了什么问题,任何帮助将不胜感激。
如何修复我的代码以允许我在我的闪存驱动器上成功启动到 Windows PE?

最佳答案

这个问题可能取决于命名为 c 的不同角度:在您运行 powershell 的那一刻和系统将要启动的那一刻之间。

你能试试这个吗?

使用 USB 驱动器启动打开控制台并键入:

bcdedit/导出 C:\SAVEDBCD

我希望 C: 在这种情况下应该对应于您的随身碟,不是吗?

然后正常重启,执行你的powershell脚本。

你应该注意到你在 $drive 中得到的 pendrive 盘符不是 c:\因为当系统启动时 C:\已经从硬盘主 Windows 分区中被占用了。

现在将先前保存的 SAVEBCD 文件与 c:\boot\bcd 中的文件进行比较,您应该使它们相等以使引导正常工作,因此您可能只需要以以下方式启动代码:

$drive="c:"

关于powershell - winpe 的 BCD 条目仅启动准备自动修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50629668/

相关文章:

WinPE - 将自定义应用程序添加到 boot.wim 或 iso

windows-10 - 从 "child"VHDX 启动 Win10 失败,并出现 VHD_BOOT_INITIALIZATION_FAILED

c - 为什么访问 C :\Windows\System32\. 的 Windows 命令 .. 在 C 程序中不起作用?

reactjs - 运行React应用程序的Azure Linux容器无法启动

powershell - 如何从 New-KMSDataKey 返回的 "Plaintext"属性的内存流中读取?

azure - 使用 Reader UMI : "Insufficient privileges to complete the operation" 获取 Azure 自动化下的 AzADUser

powershell - 如何使用单个PowerShell命令查看所有计算机级别的环境变量?

c++ - MFC:在 win32 文本区域(mfc 应用程序)中执行进程时异步(并发)显示进程的输出