I discovered a couple things today. First, VirtualBox 4 appears to be less resource intensive than Vmware Player for the same workload.
Second, while VirtualBox provides the ability to run in a headless manner (aka hidden, or in the background), the command line tool to do so must be left open (on windows at least)
…
Yeah… kinda defeats the purpose of being headless.
If you close the cmd window, it kills your VM.
The solution: well here, I’ll just attach it:
VBoxHeadlessSilent.exe
(Requires .NET Framework 4 Client Profile)
Just drop it in your c:\Program Files\Oracle\VirtualBox folder (or wherever you installed it to) and invoke it the same as you would VBoxHeadless.exe. Instead of staying open, it will print out the response from VBoxHeadless.exe and return, leaving it running in the background.
All this app does is create a process with a hidden window and passes through the parameters.
Update 9/13/2011: If you are having problems with this not working or otherwise erroring out, it might be because of spaces in the VM Name. Try renaming the VM without spaces and see if that fixes it.
(Thanks David!)
Here is the source code if you are curious.
using System; using System.Text; using System.IO; using System.Diagnostics; namespace VBoxHeadlessSilent { class Program { static void Main(string[] args) { string headlessPath = ""; string argString = ""; for (int i = 0; i < args.Length; i++) { argString += args[i] + " "; } headlessPath = Path.Combine(Environment.CurrentDirectory, "VBoxHeadless.exe"); if (!File.Exists(headlessPath)) headlessPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Oracle", "VirtualBox", "VBoxHeadless.exe"); if (!File.Exists(headlessPath)) headlessPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Oracle", "VirtualBox", "VBoxHeadless.exe"); if (File.Exists(headlessPath)) { Process p = new Process(); p.StartInfo.FileName = headlessPath; p.StartInfo.Arguments = argString; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; p.StartInfo.RedirectStandardOutput = true; p.Start(); Console.Write(p.StandardOutput.ReadToEnd()); Environment.Exit(0); } else { Console.WriteLine("Could not find VBoxHeadless.exe!"); Environment.Exit(1); } } } }