How to get VirtualBox guest’s name from guest

guest-additionsvirtualbox

In VirtualBox, is there a way to get a guest VM's own name from within that guest? The closest I found was VBoxControl guestproperty enumerate but that did not include any of aforementioned values. I'm running VirtualBox 5.1.20, Windows Server 2012 on the guest, and guest additions are installed.

Note I am able to get that information from the host by calling VBoxManage list vms.

It would also be adequate if I could set "some string property" from the host via VBoxManage that could be read by the guest via VBoxControl

Best Answer

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.

Related Question