Automatic upgrade of Guest Additions for Windows guests

Discussions about using Windows guests in VirtualBox.
Post Reply
bstewart
Posts: 2
Joined: 31. May 2023, 00:59

Automatic upgrade of Guest Additions for Windows guests

Post by bstewart »

viewtopic.php?t=36770

In the post linked above, there's a response that says "Version 4.0.0 and up will have automatic upgrade of the Guest Additions for Windows Guests."

Is this referring to the "Upgrade Guest Additions" command on the VM's "Devices" menu?
multiOS
Volunteer
Posts: 1405
Joined: 14. Sep 2019, 16:51
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux, BSD
Location: United Kingdom

Re: Automatic upgrade of Guest Additions for Windows guests

Post by multiOS »

I can't really comment on what was meant in a post from 14+ years ago, especially as both VirtualBox and Windows design have evolved somewhat in the intervening period :wink: As far as I can remember, what was mentioned back then was never implemented, but the earliest VirtualBox veriosn I vauguely remember using was 5.2.

For VirtualBox 7.1.x the current Guest Additions install/upgrade options available via the VirtualBox Manager > Devices Menu provide for both a user managed (manual) process when wanted/needed; and a more recently implemented single click (automated) upgrade process for some VMs.
bstewart
Posts: 2
Joined: 31. May 2023, 00:59

Re: Automatic upgrade of Guest Additions for Windows guests

Post by bstewart »

This is what I suspected.

For those interested in a truly automatic (hands free) upgrade of the VirtualBox Guest Additions on recent Windows clients that have PowerShell installed, I wrote a PowerShell script that does it.

https://gist.github.com/Bill-Stewart/5e ... 9ca59e2302

The script's prerequisites are:
  • The VirtualBox Guest Additions ISO must be mounted in a VM optical drive
  • The Guest Additions must already be installed
You can then use the Task Scheduler in the Windows host to execute the script at bootup. Here are the settings:
  • Run as: SYSTEM
  • Triggers: Run at system startup
  • Actions: Start a program
    Program/script: %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe
    Add arguments (optional): -ExecutionPolicy Bypass -NonInteractive -NoProfile -File "path\Update-VirtualBoxWindowsAdditions.ps1"
(Of course, replace "path\Update-VirtualBoxWindowsAdditions.ps1" with the path and filename where the script sits on the local machine, enclosed in " characters if the path contains spaces)

The script logs its activity to this file when it runs: %SystemRoot%\Logs\Update-VirtualBoxWindowsAdditions.log

The script does the following:
  • Checks the file version of the VBoxWindowsAdditions.exe installer
  • Checks the installed version using the value stored in the registry
  • If the installer's version is newer than the installed version, it runs the installer with the /S option
With this script and scheduled task in place on the Windows guest, the Guest Additions will get upgraded automatically if needed whenever I boot it (provided, of course, the Guest Additions media is mounted).
Post Reply