Search code examples
shelluefi

Get efi return code in uefi mode


I boot into uefi mode And I have a xxx.efi, I would like to get it's return code I write a startup.sh to launch the xxx.efi How could I get the xxx.efi return code? I try like this, but it will return unknow flag - '-para'

set code xxx.efi -para
echo %code%

Someone could help this orz


Solution

  • Create some script file like test.nsh then put

    MyUefiApp.efi -some_param
    @if not %LastError% == 0 then
        echo [Error] LastError = %LastError%
    @else
        echo [OK] Status = 0 [Success]
    @endif
    

    The point is that, UEFI app can check your status code through system variable LastError. UEFI Shell Spec 2.2 (It's thanks to my boss. I couldn't find this method before)