Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

Just in case somebody faces the thing again here is what I do for this...

start-process "vboxheadless" "-s ubuntu" -WindowStyle Hidden

either put it in a powershell script or type in a powershell console window. You may create a shortcut or an alias etc.

share|improve this answer
add comment

I've recently managed to do it here. The solution is not very good: I don't like Windows development.. but it works, what else can you desire? :))

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.