VirtualBox. How to script the start of the machine and installer run (windows)

I can see that I can start and stop a vm with virtualBox using VBoxManage. I m not sure this is the tool I need.

I m trying to write a script that

  1. Will boot the VM (different flavours of Windows)
  2. Run a custom piece of software (in my case an installer) and record the results of this
  3. power of the VM

I am aware of the existence of the web services and the API, however I couldnt find much online about point 2.

I would really appreciate some direction on this. ie should I use vboxmanage to start and stop the VMs and then run the installers in some other way? alternatively should I use the COM API, if so, any ideas of some samples on how to do step 2?

Not familiar with VirtualBox at all. But I can write code.

UPDATE: Should I be looking at Vagrant or Puppet? As you can probably guess this is a test suite for installers, and it would be great to be able to re use it.

Thanks


You can start a VM with

VBoxManage startvm <vm>

and power it down with

VBoxManage controlvm <vm> poweroff 

although it would be better to use acpipowerbutton:

VBoxManage controlvm <vm> acpipowerbutton

You can execute commands on the Guest using

VBoxManage guestcontrol execute ...

this works fine for command line programs and you can redirect the output to your host. However, I'm not sure how well this works with GUI applications like a normal Windows MSI installer package. Also the bit about 'recording the results' is a bit vague, does your installer write a log file that you could send to a network share before powering down the VM?

You can also take a snapshot of the VM and then look at it later


Yes, it is possible to script exactly what you describe. Allegedly it's possible to do this from a Windows host environment, but in my experience, these capabilities work fully only in Linux. (The scripting works fine in OS X too, but you can't get RDP authentication, which makes scripting in a remote system less of an interesting process.)

With the addition of some various hoop-jumping, you can also update the guest additions remotely, install/remove software, run Powershell scripts, and use WUInstall to update Windows. It's really pretty slick.

Eric