Unattended Installation of Windows Server 2008 R2 on VirtualBox
This post describes the unattended installation of a Windows Server 2008 R2 Virtual Machine in Oracle VirtualBox.
Table of Contents
General Preparations for new VM Installations
These steps have to be done once and can be used to install also other guest Operationg Systems (e.g. Linux):
Add the path of vboxmanage to the Windows Path environment variable. For example with Win+r and then enter:
rundll32 sysdm.cpl,EditEnvironmentVariables
Add C:\Program Files\Oracle\VirtualBox
to the User variable Path.
A directory c:\vms for the virtual machines on the host system should exist:
mkdir c:\vms
Preparation of the Windows Server 2008 R2 installation
Download the Windows Server 2008 R2 iso and place it in the folder c:\sw (e.g. c:\sw\Windows_Server_2008_R2_x64.iso).
Install the new Windows Server 2008 R2 VM
Configure the Virtual Machine
Run these steps in a Windows command prompt to configure the new VM. You probably need to adjust the parameter –bridgeadapter1 to the name of your primary interface of the Windows host system (ipconfig /all => see Description)
set "VHOST=" && set "MAC="
(set /p VHOST=Enter VM name ^(e.g. win1^):
set /p MAC=Enter the MAC address of the VM if you would like to use a dedicated MAC address. Press Enter to let VirtualBox assign a random MAC:
call vboxmanage createvm --name %VHOST% --ostype Windows2008_64 --register
call vboxmanage modifyvm %VHOST% --clipboard-mode=bidirectional --drag-and-drop=bidirectional --audio-controller=hda --audio-out=on
call vboxmanage modifyvm %VHOST% --memory=8192 --cpus=4 --vram=128 --graphicscontroller=vboxsvga --accelerate-3d=on --usb-xhci=on
call vboxmanage setextradata %VHOST% GUI/ScaleFactor 2
call vboxmanage storagectl %VHOST% --name "IDE" --add ide
call vboxmanage storagectl %VHOST% --name "SATA" --add sata --bootable on
call vboxmanage createmedium disk --filename c:\vms\%VHOST%\%VHOST%_1.vdi --size 122880 --variant Standard
call vboxmanage storageattach %VHOST% --storagectl "SATA" --port 0 --device 0 --type hdd --medium c:\vms\%VHOST%\%VHOST%_1.vdi
call vboxmanage modifyvm %VHOST% --nic1 bridged --bridgeadapter1 "Intel(R) Ethernet Connection (2) I219-LM"
if defined MAC call vboxmanage modifyvm %VHOST% --mac-address1=%MAC%
call vboxmanage sharedfolder add %VHOST% --name=sw --hostpath=c:\sw --automount --auto-mount-point=s:\sw
call vboxmanage showvminfo %VHOST%|findstr /C:"NIC 1")
Perform the unattended OS installation
The next command will display all installation images contained in the iso file. Select the on you wish to install and enter the Product Key:
set "img=" && set "pkey="
(vboxmanage unattended detect --iso=c:\sw\Windows_Server_2008_R2_x64.iso
set /p img=Enter the Image ^# you want to install:
set /p pkey=Enter the Windows Product Key: )
The output should be similar to:
VBoxManage.exe: info: Detected 'C:\sw\Windows_Server_2008_R2_x64.iso' to be:
OS TypeId = Windows2008_64
OS Version = 6.1.7600.16385
OS Flavor = ServerStandard
OS Languages = en-US
OS Hints =
Image #1 = Windows Server 2008 R2 Standard (Full Installation) (6.1.7600.16385 / x64 / en-US)
Image #2 = Windows Server 2008 R2 Standard (Server Core Installation) (6.1.7600.16385 / x64 / en-US)
Image #3 = Windows Server 2008 R2 Enterprise (Full Installation) (6.1.7600.16385 / x64 / en-US)
Image #4 = Windows Server 2008 R2 Enterprise (Server Core Installation) (6.1.7600.16385 / x64 / en-US)
Image #5 = Windows Server 2008 R2 Datacenter (Full Installation) (6.1.7600.16385 / x64 / en-US)
Image #6 = Windows Server 2008 R2 Datacenter (Server Core Installation) (6.1.7600.16385 / x64 / en-US)
Image #7 = Windows Web Server 2008 R2 (Full Installation) (6.1.7600.16385 / x64 / en-US)
Image #8 = Windows Web Server 2008 R2 (Server Core Installation) (6.1.7600.16385 / x64 / en-US)
Unattended installation supported = yes
Enter the Image # you want to install: 5
Enter the Windows Product Key: ***
Now start the unattended install. This will take about 10 minutes:
vboxmanage unattended install %VHOST% --iso=c:\sw\Windows_Server_2008_R2_x64.iso --image-index=%img% --key=%pkey% --user=user1 --user-password=changeme --install-additions --additions-iso="C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso" --locale=de_DE --country=DE --time-zone="Europe/Berlin" --hostname=%VHOST%.fritz.box --start-vm=gui
rem
After a reboot your new Windows 2008 R2 VM is now ready to use. Have fun!
After the OS is installed you might perform the following:
rem to be run on the host system
rem disable monitor timeout
vboxmanage guestcontrol %VHOST% run --username=Administrator --password=changeme --wait-stdout --exe "C:\Windows\System32\powercfg.exe" -- /x monitor-timeout-ac 0
Also we can set the Network Profile of the Ethernet Adapter to Private.
Installing Service Pack 1 (SP1) and Windows Updates
After the base installation of Windows Server 2008 R2 you will get the following error when you try to go to Windows Update => Search for Updates:
Code 80072EFE Windows Update encountered an unknown error
To solve this error and to be able to install the latest updates we need the following updates:
- Windows Server 2008 R2 Service Pack 1 (SP1) KB976932
- Windows Update KB4474419
- Windows Update KB4490628
- Windows Update KB4570673
- Windows Update KB4534310
I downloaded the files to s:\win2008r2updates to be able to reuse them. We install Service Pack 1 (KB976932), reboot the server and then install the next 2 updates (KB4474419 and KB4490628) and reboot the server again. Finally install the last 2 updates (KB4570673 and KB4534310) and reboot again. Now we are able to install updates from Microsoft as usual:

Further information
- If there are errors during the installation you can remove the VM configuration and all files and do a complete new installation.
- This Oracle Blog post: Guide for VirtualBox VM unattended installation
- Article by Wim Matthyssen on how to solve the Windows Update error
Leave a Reply