Print this page

Capture screenshots on VirtualBox in a Windows host


There's no easy way to do a screen capture in VirtualBox < 4.1 running Windows hosts, but this is a feature much needed by some.

I just wanted to share a bat script that makes this task easy by taking screenshots from the virtual machine you choose, and save it into a file with a different name each time you click on it (it uses date and time format)

The process is simple, but you have to know what you're doing, you do it at your own risk!

  1. Edit the Windows PATH environment variable and add your VirtualBox program files directory where vboxmanage is located. If you don't know how to do this, google for "edit windows path environment" without the quotes
  2. Download this screenshot-vbox.bat script and place it on your desktop
  3. Edit the bat script with a text editor and change the two first variables as required. You'll have to specify the exact name of the virtual machine. It is case sensitive!
  4. Save the changes done to your bat script
  5. Execute the bat script by double clicking on it and you'll get a PNG capture on your desktop

You can always modify the script to suit your destination path needs, etc... Here is the source code:


@echo off


rem ##############################################
rem # MODIFY THE TWO FOLLOWING LINES AS REQUIRED #
rem ##############################################

set VIRTUALMACHINE=win2003server
set PREFIX=capture

rem ##############################################

set dt=%date% %time%

set FILENAME=%dt:~0,2%%dt:~3,2%%dt:~6,4%_%dt:~11,2%%dt:~14,2%%dt:~17,2%.png

vboxmanage controlvm %VIRTUALMACHINE% screenshotpng %PREFIX%-%FILENAME%




.