如何将 BCD GUID 标识符和描述导出到文本文件?

How can I export BCD GUID identifier and description to text file?

我正在使用一台双布尔 Windows 机器,上面有不同版本的 Windows(8.1 和 10),我需要一种方法来记录每个安装的唯一 GUID 标识符。

目前我只能导出整个 bcdedit,这不是我想要的,我如何才能将 GUID 标识符和描述导出到一个 txt 文件中?

正如@Squashman 在评论中回答的那样,获得目标的最简单方法是

c:\Windows\System32\bcdedit.exe /enum |findstr "den des"
identifier              {bootmgr}
description             Windows Boot Manager
identifier              {current}
description             Windows 10
identifier              {cace6f08-28f0-11eb-b3c4-4c72b9b04518}
description             Windows 10

您询问了如何删除前两个条目,因此使用更多的更少:-)

c:\Windows\System32\bcdedit.exe /enum |findstr "den des" |more +2
identifier              {current}
description             Windows 10
identifier              {cace6f08-28f0-11eb-b3c4-4c72b9b04518}
description             Windows 10

如果你的下一个问题是 2+2 使用 4

c:\Windows\System32\bcdedit.exe /enum |findstr "den des" |more +4 >c:\output.txt

输出被发送到一个文件,因为您 运行 宁在一个未知但可能受保护的区域我只是发送到 c:\ 根目录,更改到临时文件夹或其他所需位置。您可以使用 type.

检查输出
C:\Windows\system32>type c:\output.txt
identifier              {cace6f08-28f0-11eb-b3c4-4c72b9b04518}
description             Windows 10

For /F "Tokens=2*" %G In ('%SystemRoot%\System32\findstr.exe "e" c:\output.txt') Do @echo %~G %~H >c:\out2.txt

然后 return 使用类型

C:\Windows\system32>type c:\out2.txt
{cace6f08-28f0-11eb-b3c4-4c72b9b04518}
Windows 10

如果要作为批处理文件添加在一起,请记住 %%var:-

RunMe.cmd(必须 运行 作为管理员,否则您将看到 bcedit 访问被拒绝将导致“系统找不到指定的文件。”)

@echo off
c:\Windows\System32\bcdedit.exe /enum |findstr "den des" |more +4>"%temp%\tempout.txt"
if exist "%temp%\tempout2.txt" del "%temp%\tempout2.txt"
For /F "Tokens=2*" %%G In ('%SystemRoot%\System32\findstr.exe "e" "%temp%\tempout.txt"') Do @echo %%~G %%~H >>"%temp%\tempout2.txt"
type "%temp%\tempout2.txt"
c:\Windows\System32>RunMe.cmd
{cace6f08-28f0-11eb-b3c4-4c72b9b04518}
Windows 10

请注意,以上结果取决于我测试中的 6 个简单条目,more +4 删除了前 4 个,这不是处理来自 bcedit.exe 的不同行数输出的稳健解决方案。所以 YMMV