batch-scripting

Parse GUID on BCDEdit command line when creating new entry

Creating an entry and setting parameters with BCDEdit on command line in a batch process can be difficult because of the random GUID generated that must be specified when changing parameters to the new entry.

With a CMD file like this:
for /f "tokens=2 delims={}" %%g in ('bcdedit.exe -store c:\boot\bcd /create /d "New Entry" /application osloader') do (set guid={%%g})
echo %guid%

The generated GUID is stored as variable and can be used, within the same batch file with variable %guid%.

Attached to the post is an example of CMD Batch file that creates and entry and sets a few parameters.