Changing VM screen resolution under Virtual Server

The other day I was asked (by a fellow Microsoft employee) how to change the resolution on a Virtual Server virtual machine. The reason why he wanted to do this was so that he could put the stand alone VMRC client into full screen mode on his laptop (which runs at 1400 x 1050) and not have to deal with bad pixel scaling due to mismatched resolutions.

So I came up with this handy little script:

vmname = InputBox("Enter the virtual machine name to resize", _
         "Virtual machine name")
vmresx = InputBox("Enter the width of the display desired" + _
         " (must be between 640 and 1600 and divisible by 8)", _
"Virtual display width")
vmresy = InputBox("Enter the height of the display desired" + _
" (must be between 480 and 1200 and divisible by 8)", _
"Virtual display height")

Set objVS = CreateObject("VirtualServer.Application")
set objVM = objVS.FindVirtualMachine(vmname)

objVM.Display.SetDimensions vmresx,vmresy

This will only work while the virtual machine is running, and if you are running a Windows virtual machine with Virtual Machine Additions installed - but it is quite handy for setting a custom, non-standard resolution (I have a couple of virtual machines configured to run at 800 x 800 now - just for giggles).

Cheers,
Ben