Vboxheadless without a command prompt (VirtualBox)

Posted by joe on Server Fault See other posts from Server Fault or by joe
Published on 2009-11-30T00:47:59Z Indexed on 2010/03/14 8:05 UTC
Read the original article Hit count: 569

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.

© Server Fault or respective owner

Related posts about Windows

Related posts about virtualbox