Using VBoxHeadless

Discussions related to using VirtualBox on Windows hosts.
Post Reply
LesDes
Posts: 66
Joined: 23. Oct 2007, 09:53
Location: London

Using VBoxHeadless

Post by LesDes »

I have started experimenting with VBoxHeadless.

1. Is there any way to hide the command window that stays open on the host "listening on port .."? It is so easy to close that window inadvertently and it seems that the VM then dies.

2. Is it possible to permanently resize the desktop? Using Guest Additions I can resize the desktop but that is then lost when the VM closes. My VMs seem to be locked at 800 x 600 when using the Windows Display Properties.

I need it to be somewhat larger so I can see a camera image in full. If I resize the desktop it by dragging the borders I end up with a non-standard resolution. When I then connect using Remote Desktop Connection I have found that the window image is all broken up unless the RD connection is sized to exactly match the desktop size.
Les
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

Use my search trick to look for srvany and also see the first stick in this forum. Wht most of us would prefer is that by default VBoxHeadless on Windows would default to a systray application. We can but wait...

Not sure about permanently resizing an RDP window. Sorry.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
LesDes
Posts: 66
Joined: 23. Oct 2007, 09:53
Location: London

Post by LesDes »

TerryE wrote:Use my search trick to look for srvany and also see the first stick in this forum.
I have read through the various threads and links (except for the long VBoxVmService thread) and got a service running - but it does not seem to be running the VM (I can still open it via the GUI)

I normally start the VM with: VBoxHeadless -startvm "Cameras"

I have done the following:

1. I have a service running called Cameras-VM

2. In the registry I have key: Parameters with value called "Application" and its value:
"C:\Program Files\Sun\xVM VirtualBox\VBoxHeadless.exe" -startvm "Cameras"

Originally I had values: AppDirectory and AppParameters and I had the string '-startvm "Cameras"' in AppParameters rather than at the end of Application but as that did not work I tried this (as per a post)

3. I added VBOX_USER_HOME into System Variables with a value "G:\Alldata\.VirtualBox\Machines" which I got from the Machines parameter in the GUI.

Can you spot what could be wrong?
Les
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

The service will be run from the NT Service account. So you need to make sure that your permissions are set up so that it can read the relevant files and that if it writes them then you can read them.

Also VBOX_USER_HOME should have the value G:\Alldata\.VirtualBox. No Machines
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
LesDes
Posts: 66
Joined: 23. Oct 2007, 09:53
Location: London

Post by LesDes »

Nearly there!

I have replaced the direct call to VBoxHeadless in the registry with a batch file with a pause.

When the service starts the command window pops up and shows the following:

Code: Select all

C:\Program Files\Sun\xVM VirtualBox>VBoxHeadless -startvm "Cameras"
VirtualBox Headless Interface 1.6.4
(C) 2008 Sun Microsystems, Inc.
All rights reserved

Invalid machine name!
I have made sure that "Everyone" has read/write/modify access to g:\

Running the same batch file from Explorer works fine.

The service is set up to run under Local System account and Allow service to interact with desktop is ticked.

I have tried to run it as Administrator and it also does not work either - the command window does not show and I cannot connect remotely.

I have tried VBOX_USER_HOME set to G:\Alldata\.VirtualBox\ and also with Machines on the end but no difference.

Why does the service need VBOX_USER_HOME anyway? The batch file runs interactively without it.
Les
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

LesDes wrote:Why does the service need VBOX_USER_HOME anyway? The batch file runs interactively without it.
Les, why don't you search the User Guide for VBOX_USER_HOME and read it if you want to ignore my advice. When you start up any VBox process it loads its registry from the folder %HOMEDRIVE%%HOMEPATH%\.VirtualBox and if it can't find one there, then it creates one. This will start with no VMs in it. The HOMEDRIVE and HOMEPATH variable will be set to something like C: and \Documents and Settings\LocalService.NT AUTHORITY\ for a service process and therefore the registry will be at C:\Documents and Settings\LocalService.NT AUTHORITY\.VirtualBox\VirtualBox.xml. It won't find your VM when it starts so it will raise the error Invalid machine name. Does this sound familiar?

The easiest way to get all users to use the same registry by default is to go into My Computer->Properties->Advanced->Environment Variables and a new System Variable VBOX_USER_HOME.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
LesDes
Posts: 66
Joined: 23. Oct 2007, 09:53
Location: London

Post by LesDes »

Thanks - I understand (I think).

So I have VBOX_USER_HOME set to G:\Alldata\.VirtualBox\ as you advised.

I think I have set permissions correctly.

Any other reason why I'm getting the "Invalid machine name!" error?
Les
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

Les, make sure that the C:\Documents and Settings\LocalService.NT AUTHORITY\.VirtualBox (or whatever the directory is called) does not exist. Reboot to make sure that the system variables are loaded. Use svrany to attempt to start your service. Then check again to make sure that the svrany process hasn't recreated this directory. The Date/timestamp of your VirtualBox.xml should have been updated. Also use the UUID. I've found that sometimes the VM name doesn't parse properly.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
LesDes
Posts: 66
Joined: 23. Oct 2007, 09:53
Location: London

Post by LesDes »

Tried with UUID. It gave a more comprihensive message but basically the same.

Did a re-boot. The xml got messed up! I ended up with an old xml in G:\Alldata\.VirtualBox with the original one left in C:\Documents and Settings\Administrator. Copied it to G:\Alldata\.VirtualBox so I have the VMs back.

Tried starting the service and I now get
-------------------------
C:\Program Files\Sun\xVM VirtualBox>VBoxHeadless -startvm "Cameras"
...
Failed to create VirtualBox object! Error info: 'Could not lock the settings file 'G:\Alldata\.VirtualBox\\VirtualBox.xml' (VERR_SHARING_VIOLATION)' (component VirtualBox).
-------------------------

So I closed the VirtualBox GUI, closed all active VMs, ended the VBoxSVC task. I then started the service and bingo! VBoxHeadless is now running and I can connect to it remotely.

Unfortunately....

VirtualBox GUI will now not run - giving
----------------
Could not lock the settings file 'G:\Alldata\.VirtualBox\\VirtualBox.xml' (VERR_SHARING_VIOLATION).
----------------

Similar errors when trying to start my other VMs using "VBoxManage startvm"

So it seems that VBoxHeadless will not coexist with the other ways of starting a VM when run from a service. Seems odd but the evidence points to that - unless I have missed something.

So back to running my VMs from a startup batch file and I will have to live with the open command screen :(

Thanks anyway for all the help - I have learned a lot.
Les
Post Reply