After rebuilding a HDD using ImageX and a WIM, the BCD sometimes gets corrupted. I therefor need to rebuid the BCD from a script running unattended in a command prompt.
The below code does the job, when entered manually. I need help to automate it (see further below code example):
bootrec.exe /fixmbr
bootsect.exe /nt60 all /force
attrib -h -s C:\boot\BCD
del C:\boot\BCD
bcdedit.exe /createstore c:\boot\bcd.temp
bcdedit.exe /store c:\boot\bcd.temp /create {bootmgr} /d "Windows Boot Manager"
bcdedit.exe /import c:\boot\bcd.temp
bcdedit.exe /set {bootmgr} device partition=C:
bcdedit.exe /timeout 10
attrib -h -s C:\boot\bcd.temp
del c:\boot\bcd.temp
bcdedit.exe /create /d "Microsoft Windows" /application osloader
bcdedit.exe /set {GUID} device partition=C:
bcdedit.exe /set {GUID} osdevice partition=C:
bcdedit.exe /set {GUID} path \Windows\system32\winload.exe
bcdedit.exe /set {GUID} systemroot \Windows
bcdedit.exe /displayorder {GUID}
As started above, I need to run this in a unattended command prompt. The output from the 6th last statement "bcdedit.exe /create /d "Microsoft Windows" /application osloader" is a newly creates GUID. This ID is needed in the following commands.
How do I load this new GUID from bcdedit to a variable I can call in the following code?
Best Regards Henrik V. Nielsen