×
Menu
Index

SETUEFIVAR Subroutine

 
Usage:
r = UEFISETVAR(varname, namespaceguid[, bindata, attributes])
 
Description:
Set a UEFI firmware variable (variable names are case sensitive). This subroutine is only available when the system booted using UEFI. In linux, the efivarfs must be mounted at /sys/firmware/efi/efivars. The linux command to mount is: mount -t efivarfs none /sys/firmware/efi/efivars. When bindata is not provided the variable is deleted. The return value is zero on success otherwise an error code is returned.
 
WARNING: This function does not prevent you from deleting variables or setting invalid data. Using invalid data or deleing the wrong variables can prevent your system from booting until the firmware is reset to factory defaults. Contact the system manufacturer for instructions on resetting factory defaults.
 
Example:
const UEFI_VAR_NV = 1
const UEFI_VAR_BS = 2
const UEFI_VAR_RT = 4
 
sub main()
   a = UEFI_VAR_NV+UEFI_VAR_BS+UEFI_VAR_RT // attributes
   t = binary(2, 3, 0, 2)                  // 16-bit value for number 2
   e = setuefivar("Timeout","{8BE4DF61-93CA-11D2-AA0D-00E098032B8C}", t, a)
   if (e = 0) then
     printl("Boot Timeout Set to", binary(t, 3))
   else
     printl("Unable to set Boot Timeout.  Error:", e)
   end if
end sub