How to get VirtualBox guest's name from guest

I have luck by setting the guestproperty in VBoxManage and VBoxControl.

On the host:

VBoxManage guestproperty set SampleVm GuestName SampleVm

Then on the guest:

VBoxControl --nologo guestproperty get GuestName

Downsides are that this requires VirtualBox Guest Additions (for VBoxControl) and an extra call from the host.