Using VBOXMANAGE to detach GUI possible?

Discussions related to using VirtualBox on Windows hosts.
Post Reply
FutureTense
Posts: 6
Joined: 26. Aug 2021, 05:17

Using VBOXMANAGE to detach GUI possible?

Post by FutureTense »

I have a windows Powershell script (follows) that takes a list of VM names from a text file and starts each of them up in headless mode.

Code: Select all

[string]$VBoxManage="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"

$ini = $MyInvocation.MyCommand.Name.Replace(".ps1",".ini")
$ini = [IO.Path]::Combine($ScriptPath,$ini)

$vms = Get-Content -Path $ini
foreach($vm in $vms)
{
    $arguments = 'startvm ' + '"' + $vm + '"' + ' --type headless'
    start-process -NoNewWindow $VboxManage $arguments 
} 
Assuming I start every VM in a headless state, how can I show and hide a VM?

For example, what would I do to the $argument variable below to show the GUI and hide/detach the GUI?

Code: Select all

foreach($vm in $vms)
{
    $arguments = 'startvm ' + '"' + $vm + '"' + ' --type headless'
    start-process -NoNewWindow $VboxManage $arguments 
} 
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Using VBOXMANAGE to detach GUI possible?

Post by scottgus1 »

Show an already-headless-started VM:

vboxmanage startvm "vm name" --type separate

There is no command line to hide a detachable/separate-started VM (Enhancement request here: https://www.virtualbox.org/ticket/16093).

There is a menu command to hide the detachable/separate-started VM's GUI in the VM window's Machine menu, Detach GUI. A Host-key combo can be set up to activate that menu command, and it may be possible to set up a host keyboard 3rd-party command script (AutoIt?) to activate the menu command or the Host-Key combo.
Post Reply