At work I have ReviewBoard running on VirtualBox on one of my development machines. This has been working great but every once in awhile I accidentally close the VirtualBox console because it’s sitting in my taskbar:
I remember reading about a ‘headless’ mode in the VirtualBox documentation. This will setup VirtualBox running as a RDP server – it can run ‘invisibly’ and you can connect via Windows Remote Desktop to intact with the system.
You can either configure the remote settings within the VirtualBox GUI:
Or pass them in through the command line. I went this route and created a batch file called start-reviewboard.bat:
REM Batch script to start VirtualBox instance of ReviewBoard in headless mode REM Connect via RDP (Remote Desktop Protocol) to port 8000 "C:\Program Files\sun\VirtualBox\VBoxHeadless.exe" -startvm ReviewBoard -p 8000
This starts VirtualBox in headless mode (VBoxHeadless.exe), starts my ReviewBoard vm, and sets up RDP (port 8000).
You can run this script and it should start VirtualBox – but you will still be left with a DOS box sitting there in your taskbar. Turns out it is fairly easy to write a small script to run a batch file silently as well. I created start-reviewboard.vbs:
REM 0 = hide window, 1 = show window (useful for debugging)
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "D:\scripts\start-reviewboard.bat" & Chr(34), 0
Set WshShell = Nothing
You use this script to run your batch file and pass in a parameter to hide the window (0). I’d recommend setting that to 1 while you get things setup so you can see what is going on and once you have worked out the kinks set it to 0.
When you run it – you should get a DOS window and a message “Listening on port 8000” (or whatever you set the port to). I changed the port to 8000 as I assume Windows is already using 3389 (default RDP port).
To connect I simply start Remote Desktop Connection and enter localhost:8000.
To stop VirtualBox simply issue the following command:
VBoxManage controlvm YOUR_VM_NAME poweroff


pretty slick Jim!
Know its a little late, but this was really helpful, thanks!
I had to change the “&”s in your vb script to regular “&” to make it work for me but this is great.
I’m sure you must have known, but just to inform people who find this article thru google search, aside from this method, you can also use VBoxVMService to run VMs as service ( http://sourceforge.net/projects/vboxvmservice/ )
Hey! Great script. Will make my life a little more easier…
This is what I was looking for. Thanks dude.
This is great. Thanks!
Also, just to let you know, the vbs script has” &” instead of “&”. If someone reading this didn’t know anything about VB, then this might really be confusing.
Thanks again!
change “C:\Program Files\sun\VirtualBox\VBoxHeadless.exe” -startvm ReviewBoard -p 8000
to
start “” “C:\Program Files\sun\VirtualBox\VBoxHeadless.exe” -startvm ReviewBoard -p 8000
In batch files, calling the executable directly will make it wait for execution to complete (start /wait). using “start” will continue the script and exit, leaving you with a running vbox, no cmd window, and no messy leftover processes.
Great tip! Thanks for sharing!
They for the info!
You can skip the batch file step and run this headless right from your vb script like so.
dim strScriptstrScript = chr(34) & "C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe" & chr(34) & " -startvm ubuntu-dev -p 8000"
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run strScript, 0
Set WshShell = Nothing
Thanks for the information!
Thanks, Derak, for the suggested improvement to the script! Very nice!
This is much better. Everything goes into one VBS file and it launches!
Hint: Open VirtualBox Manager to check whether the VirtualMachine is running! :)