Change resolution from command line in virtual box

In virtual box, how can I change the screen resolution from the command line? (Or if there's one for any type of computer, that might work too).


Solution 1:

You can quickly "hint" the window to a specific size with the following command:

VBoxManage controlvm <uuid>|<name> setvideomodehint <xres> <yres> <bpp>

For example, if you have a guest called "Windows XP Pro", and you wish to set the resolution to 1024x600 at 32 bits per pixel (aka 32 bit) you would use the following command:

VBoxManage controlvm "Windows XP Pro" setvideomodehint 1024 600 32

There are some prerequisites for this however:

  1. This only works if you've launched the Guest OS from a windowed environment on the Host OS (ie. Windows / X Windows / Mac OS Desktop).

  2. Guest Additions must be installed in the Guest OS.

Solution 2:

First, the vm must be turned on, you can power on with command:

# VBoxManage startvm "VPN" --type headless

Before you can change the resolution:

# VBoxManage controlvm "VPN" setvideomodehint 1024 768 24