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

Time:09-17

I'm using a dual bool Windows machine with different versions of Windows on it (8.1 and 10) and I need a way of noting each installs unique GUID identifier.

Currently I can only export the entire bcdedit which is not what I'm after, how can I export the GUID identifiers and the descriptions ONLY into a txt file?

enter image description here

CodePudding user response:

As @Squashman answered in comments the simplest way to get your target(s) is

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

You asked how to remove top two entries, so use more for less :-)

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

and if your next question is 2 2 use 4

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

the output is sent to a file which because you are running in an unknown but likely protected zone I simply sent to the c:\ root directory, change to the temporary folder or other desired location. You can check the output with type.

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

and

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

will then return using type

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

Remember for %%var if you are adding together as a batch file:-

RunMe.cmd (MUST BE run as administrator, otherwise you will see that bcedit access denied will result in "The system cannot find the file specified.")

@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

Note the above result depends on 6 simple entries from my tests and more 4 removes the first 4 it is not a robust solution to deal with varying number of lines output from bcedit.exe. so YMMV

  • Related