Wednesday, February 10, 2010

VirtualBox: Autostart guest in Windows XP host

Some time ago I was asked to quickly setup a temporary LAMP server. Since, the time was an issue and it was supposed to be only a short-term solution I decided to take a PC box with Windows XP, install a VirtualBox, and setup an Ubuntu server 8.04 LST as a guest operating system.

Unfortunately, it was over a 1.5 year ago and what was a short-term solution become now de-facto a long term one. However, recently we had some power shortages in our building, and the problem appeared with this PC box, i.e. after it went down due to power shortage it did not start VirtualBox automatically when being turned on. Thus, I was asked to make it start automatically, in such a way that after turning the PC on, everything VirtualBox and ubuntu-server start automatically. I did it in to steps:

1. Setup autologin in Windows XP.

To do this I followed instructions from here.

2. Make VirtualBox start automatically.
To do this I wrote very simple Windows batch script called startVB.bat that contained the following two lines:cd "C:\Program Files\Sun\xVM VirtualBox"
vboxmanage startvm "ubuntu-server"
where "ubuntu-server" is the name of virtual machine to be started. The script was located in Startup folder C:\Documents and Settings\MY_USER_NAME\Start Menu\Programs\Startup.