19

I was required to develop a Windows app UI for a fixed resolution - it doesn't matter if it makes sense or not, the customer requires it. I'm using a Windows Server 2003 VirtualBox VM as the development environment; my host machine has much higher resolution.

Is there any way to select and fix the OS resolution and stop VirtualBox changing it by any kind of scaling? I can't see the requested resolution when I open Display Properties on the guest OS.

7 Answers 7

11

So I tried this, and might work for you. Under the Machine menu, there is an option to auto-resize the guest OS's resolution to fit the monitor you are using. I got the resolution you did by enabling this option, manually resizing the window to get the resolution I wanted, then DISABLING auto-resize. Then, it's "stuck" there and I can resize the window, move it around, resolution doesn't change. Only problem was the taskbar. While you are doing the resize, might help to minimize it to get the exact resolution

0
10

For my setup, neither CustomVideoMode1 nor setvideomodehint nor MaxGuestResolution worked. So, I looked up

vboxmanage getextradata $YOUR_VM_NAME enumerate

and changed

Key: GUI/LastGuestSizeHint, Value: 800,600

to

Key: GUI/LastGuestSizeHint, Value: 1920,1080

with

vboxmanage setextradata $YOUR_VM_NAME GUI/LastGuestSizeHint 1920,1080

4
  • 4
    This was hugely helpful in letting me set the size of a VM in Vagrant + Virtualbox. I wanted to be able to resize the VM to any resolution after it was booted, but always have it start up and switch to a certain resolution, so I added vb.customize ['setextradata', :id, 'GUI/LastGuestSizeHint','1280,800'] to my Vagrantfile and it is working great.
    – dragon788
    Commented Dec 5, 2019 at 15:16
  • Same as the answer above, except I had to escape the forward slash within the key (or perhaps, it works as is as long as you are you using single quotes): vb.customize ["setextradata", :id, "GUI\/LastGuestSizeHint", "1920,1080"] Commented Oct 8, 2022 at 6:21
  • 1
    @GeorgeSmith that is because you used double quotes which require escaping while allowing for variables and parameter expansion as well as other string interpolations. Single quoted string literals do not. Commented Oct 10, 2022 at 6:13
  • 1
    @MikaFeiler, Thank you so much for explaining. Just some context. I tried to use your examples as :after triggers in Vagrant and from within the Vagrantfile (Vagrant provides a way to call vobxmanage from within the file). It appears that after logging in, the resolution is as expected, but the initial login screen resolution is still 800x600. It works fine after logging in and logging back in. If you have any suggestions about the initial login screen, please, respond. Thanks in advance :) Commented Oct 11, 2022 at 8:43
6

While the VM is running, define your custom resolution using this command:

vboxmanage setextradata "[VM NAME]" CustomVideoMode1 1600x900x32

While the VM is running, execute the following command to switch to your new resolution:

vboxmanage controlvm "[VM NAME]" setvideomodehint 1600 900 32

It should switch to the new resolution immediately.

For this to work you must have VirtualBox Guest Extensions installed in the VM.

5
  • Does not work FOR ME on Windows 10. The vbox window does not change its resolution.
    – kiltek
    Commented Apr 8, 2020 at 6:03
  • You must have VirtualBox Guest Extensions installed in your VM for those commands to work. Commented Jul 11, 2020 at 16:48
  • Brilliant! Worked for me in Windows 7 (Tiny7). Got an error setting before boot of VM, but second one worked after a few seconds.
    – Sun
    Commented Jan 22, 2021 at 6:03
  • @Sun I did write "While the VM is running" so I am not sure why you are surprised it didn't work before it booted. Commented Apr 14, 2021 at 19:48
  • For me this worked only using the VBoxSVGA graphics controller on a Linux host with a Win 10 guest. Commented Apr 16, 2021 at 12:19
5

Try installing Guest Additions. It provides lots more features to the guest OS. From there, you can leverage the resolution you want and lock the screen in that position.

5
  • I have Guest Additions. Problem is the resolution I need is never allowed as in the resolution selection slider in guest OS.
    – Random
    Commented Jun 24, 2011 at 2:40
  • 2
    What is the resolution, exactly?
    – Camron B
    Commented Jun 24, 2011 at 12:56
  • 1
    You may need to install the guest additions when running in safe mode. I have seen several instances where the video driver did not completely install when not in safe mode - particularly for 3D acceleration.
    – Goyuix
    Commented Jun 24, 2011 at 19:03
  • Requested resolution is 1440x900 (HP LE1901w native) host resolution is 1920x1080
    – Random
    Commented Jun 25, 2011 at 10:19
  • 3
    So I tried this, and might work for you. Under the Machine menu, there is an option to auto-resize the guest OS's resolution to fit the monitor you are using. I got the resolution you did by enabling this option, manually resizing the window to get the resolution I wanted, then DISABLING auto-resize. Then, it's "stuck" there and I can resize the window, move it around, resolution doesn't change. Only problem was the taskbar. While you are doing the resize, might help to minimize it to get the exact resolution
    – Camron B
    Commented Jun 25, 2011 at 15:57
4

Even with Guest Additions installed, my remote Windows is not able to give me my wished 1920x1080 so I used this solution

vboxmanage startvm "mymachine";vboxmanage controlvm "mymachine" setvideomodehint 1920 1080 32
1
  • Does not work FOR ME on Windows 10. The VM does not boot anymore. How to revert this setting?
    – kiltek
    Commented Apr 8, 2020 at 6:08
3

I was having the same problem as described above nothing was working even the manual setting of screen resolution, I solved my problem with checking some things:

  1. In VirtualBox Manager GUI checked my OS version: I have chosen Windows 8.1 64 bit, but guest OS was 32 bit which, was the main problem
  2. Solution: new machine with win 8.1 32 bit OS and linked to an old virtual hard drive
  3. Setting machine custom resolution with VBoxManage command line

    VBoxManage.exe setextradata "[Virtual Machine Name]" CustomVideoMode1 1366x768x32
    
2

From with Vagrant file - see the last line with LastGuestSizeHint, I had to escape the slash after GUI in order for this to work:

Vagrant.configure("2") do |config|
    config.vm.box = "codeup/Ubuntu-20.04-GUI"
    config.vm.provider "virtualbox" do |vb|
        vb.gui = true
        vb.name = "Eclipse"
        vb.memory = 2048
        vb.cpus = 2
        vb.customize ["modifyvm", :id, "--vram", 256]
        vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
        vb.customize ["modifyvm", :id, "--draganddrop", "bidirectional"]
        vb.customize ["setextradata", :id, "GUI\/LastGuestSizeHint", "1920,1080"]
    end
2
  • This is what I was looking for: a programmatic way to tell VBox to resize the window, thank you
    – elmazzun
    Commented Aug 15, 2023 at 12:42
  • You are welcome. Hope things work out end to end :). Commented Dec 23, 2023 at 23:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .