Is It Possible To Query The Host's Name From Within A Guest?
-
saberman
- Posts: 292
- Joined: 21. Dec 2009, 00:32
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows XP, 7, 8.1, 10
Is It Possible To Query The Host's Name From Within A Guest?
Host: Windows 8.1 Pro x64
Guest: Windows 7 Ultimate x64
I have a development/testing environment where a VM may be moved from one host to another. Each of the hosts have the same set of folders. I want to be able to dynamically map a couple of the host's folders when a user signs into a VM. For example, consider the following folder structure on the host:
V:\VirtualBox (Shared as VirtualBox)
V:\VirtualBox\Data1
V:\VirtualBox\Data2
Host: Host1
When a user logs into the VM I want to map
G ==> \\<hostname>\VirtualBox\Data1
H ==> \\<hostname>\VirtualBox\Data2
I can used shared folders for this as they do provide full Windows support.
If I can grab the host's name I can write a little utility that will be called from a login script to do the mapping.
Guest: Windows 7 Ultimate x64
I have a development/testing environment where a VM may be moved from one host to another. Each of the hosts have the same set of folders. I want to be able to dynamically map a couple of the host's folders when a user signs into a VM. For example, consider the following folder structure on the host:
V:\VirtualBox (Shared as VirtualBox)
V:\VirtualBox\Data1
V:\VirtualBox\Data2
Host: Host1
When a user logs into the VM I want to map
G ==> \\<hostname>\VirtualBox\Data1
H ==> \\<hostname>\VirtualBox\Data2
I can used shared folders for this as they do provide full Windows support.
If I can grab the host's name I can write a little utility that will be called from a login script to do the mapping.
-
noteirak
- Site Moderator
- Posts: 5231
- Joined: 13. Jan 2012, 11:14
- Primary OS: Debian other
- VBox Version: OSE Debian
- Guest OSses: Debian, Win 2k8, Win 7
- Contact:
Re: Is It Possible To Query The Host's Name From Within A Gu
You can't query the host name from virtualbox itself, no.
What is possible on the other hand would be to set a custom guestproperty from the host and then get this back from the guest.
What is possible on the other hand would be to set a custom guestproperty from the host and then get this back from the guest.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Manage your VirtualBox infrastructure the free way!
-
saberman
- Posts: 292
- Joined: 21. Dec 2009, 00:32
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows XP, 7, 8.1, 10
Re: Is It Possible To Query The Host's Name From Within A Gu
>set a custom guestproperty from the host and then get this back from the guest.
Is there a simple way to do that?
If not I think I will setup a shared folder for the purpase of having a cmd file in a folder called Startup that will do the mapping. The login script in the guest would run the cmd file. Each host would have the same file folder and cmd file but with the host's name in the cmd file. It will waste a drive letter as the folder will have to be statically mapped in the guest.
Is there a simple way to do that?
If not I think I will setup a shared folder for the purpase of having a cmd file in a folder called Startup that will do the mapping. The login script in the guest would run the cmd file. Each host would have the same file folder and cmd file but with the host's name in the cmd file. It will waste a drive letter as the folder will have to be statically mapped in the guest.
-
ChipMcK
- Volunteer
- Posts: 1095
- Joined: 20. May 2009, 02:17
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, OSX
- Location: U S of A
Re: Is It Possible To Query The Host's Name From Within A Gu
check out HOWTO: Use Guest Propertiessaberman wrote:>set a custom guestproperty from the host and then get this back from the guest.
Is there a simple way to do that?
google search guestproperty site:forums.virtualbox.org
-
rpmurray
- Volunteer
- Posts: 918
- Joined: 3. Mar 2009, 00:29
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows 7, Mac OS X (various flavors)
- Location: Between Heaven and Hell
Re: Is It Possible To Query The Host's Name From Within A Gu
I'm assuming this only works if you have Guest Additions installed in the guest?ChipMcK wrote:check out HOWTO: Use Guest Properties
Edit: Yes, that's the case. From the manual:
4.6 Guest properties. Starting with version 2.1, VirtualBox allows for requesting certain properties from a running guest, provided that the VirtualBox Guest Additions are installed and the VM is running.
-
saberman
- Posts: 292
- Joined: 21. Dec 2009, 00:32
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows XP, 7, 8.1, 10
Re: Is It Possible To Query The Host's Name From Within A Gu
The link has:ChipMcK wrote:check out HOWTO: Use Guest Propertiessaberman wrote:>set a custom guestproperty from the host and then get this back from the guest.
Is there a simple way to do that?
google search guestproperty site:forums.virtualbox.org
On the Host the properties are accessed through VBoxManage command with the following qualifiers:guestproperty get <vmname>|<uuid> <property> [-verbose]
guestproperty set <vmname>|<uuid> <property> [<value> [-flags <flags>]]
guestproperty enumerate <vmname>|<uuid> [-patterns <patterns>]
and on the Guest with the corresponding VBoxControl commands
guestproperty get <property> [-verbose]
guestproperty set <property> [<value> [-flags <flags>]]
guestproperty enumerate [-patterns <patterns>]
I am sure that is very meaningful to someone working with the VitrualBox SDK but it is meaningless to me. I need to be able to set a property that is passed to all VMs on the host. I also do not see how I can retieve the property in the guest programatically -- they appear to be command line commands.
I will try the shared folder with a script approach. At least I understand that.
-
ChipMcK
- Volunteer
- Posts: 1095
- Joined: 20. May 2009, 02:17
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, OSX
- Location: U S of A
Re: Is It Possible To Query The Host's Name From Within A Gu
I do not have the SDK installed and the commands work without errors. Yes, you will need to develop script files using the commands, just as you will for the 'shqred folders' approach.saberman wrote: I am sure that is very meaningful to someone working with the VitrualBox SDK but it is meaningless to me. I need to be able to set a property that is passed to all VMs on the host. I also do not see how I can retieve the property in the guest programatically -- they appear to be command line commands.
-
saberman
- Posts: 292
- Joined: 21. Dec 2009, 00:32
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows XP, 7, 8.1, 10
Re: Is It Possible To Query The Host's Name From Within A Gu
>Yes, you will need to develop script files using the commands
Any example of having the script on the host side run everytime a VM is started?
Any example of having the script on the host side run everytime a VM is started?
-
ChipMcK
- Volunteer
- Posts: 1095
- Joined: 20. May 2009, 02:17
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, OSX
- Location: U S of A
Re: Is It Possible To Query The Host's Name From Within A Gu
you are joking, yes?
You might try reading the * manual.
8.30. VBoxManage guestproperty
and
4.6. Guest properties
Life is easier if you RTFM
You might try reading the * manual.
8.30. VBoxManage guestproperty
and
4.6. Guest properties
Life is easier if you RTFM
-
saberman
- Posts: 292
- Joined: 21. Dec 2009, 00:32
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows XP, 7, 8.1, 10
Re: Is It Possible To Query The Host's Name From Within A Gu
>You might try reading the * manual.
I did before I posted. Now please point me to the part that explains how to trigger the VBoxManage guestproperty command automatically after VirtualBox starts a guest VM sending the host's name as the value of the property.
I did before I posted. Now please point me to the part that explains how to trigger the VBoxManage guestproperty command automatically after VirtualBox starts a guest VM sending the host's name as the value of the property.
-
ChipMcK
- Volunteer
- Posts: 1095
- Joined: 20. May 2009, 02:17
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, OSX
- Location: U S of A
Re: Is It Possible To Query The Host's Name From Within A Gu
I did not realize that English is not your native language
Comprehend?
edited: substitute "only" in place of "but"
TRANSIENT: the value will not be stored with the VM data when the VM exits; means that the VBoxManage guestproperty set command needs be issued only once. BTW, VBox does not need to be active for my V4.3.10set <vm> <property> [<value> [--flags <flags>]]: This allows you to set a guest property by specifying the key and value. If <value> is omitted, the property is deleted. With --flags you can optionally specify additional behavior (you can combine several by separating them with commas):
TRANSIENT: the value will not be stored with the VM data when the VM exits;
TRANSRESET: the value will be deleted as soon as the VM restarts and/or exits;
Comprehend?
edited: substitute "only" in place of "but"
Last edited by ChipMcK on 28. Apr 2014, 12:49, edited 1 time in total.
-
saberman
- Posts: 292
- Joined: 21. Dec 2009, 00:32
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows XP, 7, 8.1, 10
Re: Is It Possible To Query The Host's Name From Within A Gu
>Comprehend?
No. Here is the scenario:
1. Copy the environment -- everything associated with VirtualBox -- to another host.
2. Click on a shortcut to start a VM.
3. User logs into the VM.
As I understand it, a request from the host to set a property has to be made when a VM is running. Exactly where do I put a script to set a property with the host's name that will execute automatically immediately after the VM starts but before the first user logins into the VM?
No. Here is the scenario:
1. Copy the environment -- everything associated with VirtualBox -- to another host.
2. Click on a shortcut to start a VM.
3. User logs into the VM.
As I understand it, a request from the host to set a property has to be made when a VM is running. Exactly where do I put a script to set a property with the host's name that will execute automatically immediately after the VM starts but before the first user logins into the VM?
-
ChipMcK
- Volunteer
- Posts: 1095
- Joined: 20. May 2009, 02:17
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, OSX
- Location: U S of A
Re: Is It Possible To Query The Host's Name From Within A Gu
The VBoxManage guestproperty set command is issued during the previous week, when you decide what key and its value for your VMs.saberman wrote:>Comprehend?
No. Here is the scenario:
1. Copy the environment -- everything associated with VirtualBox -- to another host.
2. Click on a shortcut to start a VM.
3. User logs into the VM.
As I understand it, a request from the host to set a property has to be made when a VM is running. Exactly where do I put a script to set a property with the host's name that will execute automatically immediately after the VM starts but before the first user logins into the VM?
And the target VMs need not be active at the moment that VBoxManage guestproperty set command is issued
.
-
saberman
- Posts: 292
- Joined: 21. Dec 2009, 00:32
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows XP, 7, 8.1, 10
Re: Is It Possible To Query The Host's Name From Within A Gu
>during the previous week
This is a development environment. I shift hosts at least once a day and sometimes multiple times a day. The porocess has to be fully automated including inserting the name of the host in the guestproperty command.
>target VMs need not be active at the moment that VBoxManage guestproperty set command is issued
From the manual:
The “guestproperty” commands allow you to get or set properties of a running virtual machine.
I think the shared folder approach is easier and safer.
This is a development environment. I shift hosts at least once a day and sometimes multiple times a day. The porocess has to be fully automated including inserting the name of the host in the guestproperty command.
>target VMs need not be active at the moment that VBoxManage guestproperty set command is issued
From the manual:
The “guestproperty” commands allow you to get or set properties of a running virtual machine.
I think the shared folder approach is easier and safer.
-
ChipMcK
- Volunteer
- Posts: 1095
- Joined: 20. May 2009, 02:17
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, OSX
- Location: U S of A
Re: Is It Possible To Query The Host's Name From Within A Gu
Not on my v4.3.10. That VM need not be active. It setting becomes part of the VM definition, unlesssaberman wrote:>target VMs need not be active at the moment that VBoxManage guestproperty set command is issued
From the manual:
The “guestproperty” commands allow you to get or set properties of a running virtual machine.
set <vm> <property> [<value> [--flags <flags>]]: This allows you to set a guest property by specifying the key and value. If <value> is omitted, the property is deleted. With --flags you can optionally specify additional behavior (you can combine several by separating them with commas):
TRANSIENT: the value will not be stored with the VM data when the VM exits;
TRANSRESET: the value will be deleted as soon as the VM restarts and/or exits;