I'm trying to run VirtualBox VM's in the background from a service. I'm having trouble starting a process the way I desire. I'd like to start the virtualbox guest in headless mode as a separate process and show nothing as far as GUI.
Here's what I've tried:
From command line:
start vboxheadless -s "Ubuntu Server"
In C#:
ProcessStartInfo info = new ProcessStartInfo
{
UseShellExecute = false,
RedirectStandardOutput = true,
ErrorDialog = false,
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "C:/program files/sun/virtualbox/vboxheadless",
Arguments = "-s \"Ubuntu Server\""
};
Process p = new Process();
p.StartInfo = info;
p.Start();
String output = p.StandardOutput.ReadToEnd(); //BLOCKS! (output stream isnt closed)
I want to be able to get the output to know if starting the server was a success. However, it seems as though the window that's spawned never closes its output stream.
It's also worth mentioning that I've tried using vboxmanage startvm "Ubuntu Server" --type=vrdp. I can determine whether the server started properly using this. But it shows a new command prompt window for the newly started VirtualBox guest.