NTSTATUS
NtSetSystemEnvironmentValueEx(
  IN  PUNICODE_STRING VariableName,
  IN  LPGUID VendorGuid,
  IN  PVOID Value,
  IN  ULONG ValueLength,
  IN  ULONG Attributes
  );

Routine Description:

    This function sets the specified system environment variable to the
    specified value.

    N.B. This service requires the system environment privilege.

Arguments:

    VariableName - Supplies a pointer to a UNICODE descriptor for the specified
        system environment variable.

    VendorGuid - Supplies the GUID for the vendor associated with the variable.
        Variables are grouped into namespaces based on their vendor GUIDs. Some
        platforms may not support vendor GUIDs. On these platforms, all
        variables are in a single namespace, and this routine ignores VendorGuid.

    Value - Supplies a pointer to a buffer that contains the new variable value.

    ValueLength - Supplies the length in bytes of the Value buffer.

    Attributes - Supplies the attributes of the variable. The attribute bit
        VARIABLE_ATTRIBUTE_NON_VOLATILE MUST be set.

Return Value:

    STATUS_SUCCESS              The function succeeded.
    STATUS_INSUFFICIENT_RESOURCES Insufficient system resources exist
                                  for this request to complete.
    STATUS_INVALID_PARAMETER    One of the parameters is invalid.
    STATUS_NOT_IMPLEMENTED      This function is not supported on this platform.
    STATUS_UNSUCCESSFUL         The firmware returned an unrecognized error.
    STATUS_PRIVILEGE_NOT_HELD   The caller does not have the required privilege.
    STATUS_ACCESS_VIOLATION     One of the input parameters cannot be read.