[HELP] UEFI Boot into WinPE or UEFI Shell

Discussion in 'Scripting' started by Flipp3r, Jul 4, 2019.

  1. Flipp3r

    Flipp3r MDL Expert

    Joined:
    Feb 11, 2009
    Messages:
    1,743
    Likes Received:
    772
    Trophy Points:
    60
    I'm trying to add a BCD entry to be able to boot into either WinPE or UEFI Shell from USB.
    When I select "UEFI Shell" I get an error 0xC000007B.
    I'm running this batch file from an admin cmd prompt from my usb key which is J:
    Code:
    @echo off
    
    FOR /F "delims={} tokens=2" %%I IN ('bcdedit /store EFI\Microsoft\boot\bcd /copy {bootmgr} /d "UEFI Shell"') DO SET OSGUID=%%I
    SET OSGUID={%OSGUID%}
    
    bcdedit /store EFI\Microsoft\boot\bcd /set %OSGUID% device partition=J:
    bcdedit /store EFI\Microsoft\boot\bcd /set %OSGUID% path \EFI\Boot\Shellx64.efi
    
    bcdedit /store EFI\Microsoft\boot\bcd /deletevalue %OSGUID% locale
    bcdedit /store EFI\Microsoft\boot\bcd /deletevalue %OSGUID% inherit
    bcdedit /store EFI\Microsoft\boot\bcd /deletevalue %OSGUID% default
    bcdedit /store EFI\Microsoft\boot\bcd /deletevalue %OSGUID% resumeobject
    bcdedit /store EFI\Microsoft\boot\bcd /deletevalue %OSGUID% displayorder
    bcdedit /store EFI\Microsoft\boot\bcd /deletevalue %OSGUID% toolsdisplayorder
    ::bcdedit /store EFI\Microsoft\boot\bcd /deletevalue %OSGUID% timeout
    
    :: bcdedit /store EFI\Microsoft\boot\bcd /set {fwbootmgr} displayorder %OSGUID% /addfirst
    bcdedit /store EFI\Microsoft\boot\bcd /displayorder %OSGUID% /addfirst
    
    bcdedit /store EFI\Microsoft\boot\bcd /timeout 30
    bcdedit /store EFI\Microsoft\boot\bcd /deletevalue {default} bootmenupolicy
    I've also tried this:
    Code:
    @echo off
    
    ::FOR /F "delims={} tokens=2" %%I IN ('bcdedit /store EFI\Microsoft\boot\bcd /create /d "UEFI Shell"  /application BOOTSECTOR') DO SET OSGUID=%%I
    FOR /F "delims={} tokens=2" %%I IN ('bcdedit /store EFI\Microsoft\boot\bcd /copy {bootmgr} /d "UEFI Shell"') DO SET OSGUID=%%I
    SET OSGUID={%OSGUID%}
    bcdedit /store EFI\Microsoft\boot\bcd /set %OSGUID% device partition=J:
    bcdedit /store EFI\Microsoft\boot\bcd /set %OSGUID% path \EFI\Boot\bootx64.efi
    bcdedit /store EFI\Microsoft\boot\bcd /displayorder %OSGUID% /addlast
    bcdedit /store EFI\Microsoft\boot\bcd /timeout 30
    ::bcdedit /store EFI\Microsoft\boot\bcd /deletevalue {default} bootmenupolicy
    I have both shellx64.efi and bootx64.efi on my usb key (they are both different).
    What am I doing wrong??