Gru*_*ica 7 powershell winpe bcdedit
我正在尝试将计算机重新启动到包含Windows PE的闪存驱动器介质中,但每次只启动准备自动修复.这是我的powershell生成新的bcd条目:
$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
Run Code Online (Sandbox Code Playgroud)
所有操作都已成功完成,看起来好像条目是正确的:
但是,当我重新启动计算机时,我曾经收到消息"修复自动恢复",然后最终进入Windows恢复环境.我已经添加bcdedit /set $variable recoveryenabled No
,这使得它不可能进入恢复环境,但我现在得到一个不同的错误:
无法加载应用程序或操作系统,因为缺少必需的文件或包含错误.
文件:\ EFI\Boot\bootx64.efi错误代码:0xc000007b
但是,如果我进入启动选项并手动选择此文件,它会启动到winpe就好了.
我不确定出了什么问题,任何帮助都会非常感激.
如何修复我的代码以允许我成功启动到闪存驱动器上的Windows PE?
A. *_*ion -1
这个问题可能取决于从运行 powershell 到系统启动之间的 c: 名称的不同角度。
你能试试这个吗?
使用 USB 驱动器启动打开控制台并键入:
bcdedit /导出C:\SAVEDBCD
我希望在这种情况下 C: 应该对应于您的随身碟,不是吗?
然后正常重启,执行你的powershell脚本。
您应该注意到,您在 $drive 中获得的随身碟盘符不是 c:\,因为当系统启动时,C:\ 已经被硬盘主 Windows 分区占用。
现在将之前保存的 SAVEBCD 文件与 c:\boot\bcd 中的文件进行比较,您应该使它们相等才能启动正常工作,因此您可能只需要使用以下命令启动代码:
$drive="c:"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
339 次 |
最近记录: |