-1

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

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

在此处输入图像描述

4

1 回答 1

1

正如@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:\ 根目录,更改到临时文件夹或其他所需位置。您可以使用类型检查输出。

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

然后将使用类型返回

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

于 2021-09-14T20:52:38.740 回答