Discussion:
How to start VirtualBox minimized
(too old to reply)
Gary Kuznitz
2014-05-31 00:34:03 UTC
Permalink
I found this bat file on the internet.

It does start the guest OS but it doesn't start minimized.

Does anyone have any idea what I need to do to get the guest OS to start
minimized?

Thank you,

Gary

@echo off
:: This will start a VirtualBox guest minimized
::
:: To get the ID run:
:: vboxmanage list vms
::
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
rem Anything after here will run in a minimized window
rem bring the current directoty forward and change drives cause windows normally
starts your process from system32
rem bringing the process forward to the script location means it will launch
myscript
from its location
%~d0
CD %~dp0
cls
rem Open the folder in a new process and close/exit this one
start /wait /b C:\Programs\VirtualBox\VirtualBox.exe --startvm
"c2f7cf76-be3e-496f-8e77-f2823e65c5bd" /SEPARATE/N
exit
Todd Vargo
2014-05-31 03:24:06 UTC
Permalink
Post by Gary Kuznitz
I found this bat file on the internet.
It does start the guest OS but it doesn't start minimized.
Does anyone have any idea what I need to do to get the guest OS to start
minimized?
Thank you,
Gary
@echo off
:: This will start a VirtualBox guest minimized
:: vboxmanage list vms
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
rem Anything after here will run in a minimized window
rem bring the current directoty forward and change drives cause windows normally
starts your process from system32
rem bringing the process forward to the script location means it will launch
myscript
from its location
%~d0
CD %~dp0
cls
rem Open the folder in a new process and close/exit this one
start /wait /b C:\Programs\VirtualBox\VirtualBox.exe --startvm
"c2f7cf76-be3e-496f-8e77-f2823e65c5bd" /SEPARATE/N
exit
Add the /min switch to the start command.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
Gary Kuznitz
2014-05-31 15:38:37 UTC
Permalink
Post by Todd Vargo
Post by Gary Kuznitz
I found this bat file on the internet.
It does start the guest OS but it doesn't start minimized.
Does anyone have any idea what I need to do to get the guest OS to start
minimized?
Thank you,
Gary
@echo off
:: This will start a VirtualBox guest minimized
:: vboxmanage list vms
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
rem Anything after here will run in a minimized window
rem bring the current directoty forward and change drives cause windows normally
starts your process from system32
rem bringing the process forward to the script location means it will launch
myscript
from its location
%~d0
CD %~dp0
cls
rem Open the folder in a new process and close/exit this one
start /wait /b C:\Programs\VirtualBox\VirtualBox.exe --startvm
"c2f7cf76-be3e-496f-8e77-f2823e65c5bd" /SEPARATE/N
exit
Add the /min switch to the start command.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
That worked very nicely. Thank you.

I'd like to understand a little of what this bat file does.

When it says:
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized

Does this mean the first time through %minimized% will always equal null so it will goto minimized every time?
Will it ever get to the set minimized=true statement? How?
If it does get to the set minimized=true statement it seems to me it should call this bat file with the /min on the start.

Thanks,

Gary
foxidrive
2014-05-31 15:46:18 UTC
Permalink
Post by Gary Kuznitz
I'd like to understand a little of what this bat file does.
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
It's minimising the batch file, not the application.
Todd Vargo
2014-05-31 21:29:31 UTC
Permalink
Post by Gary Kuznitz
That worked very nicely. Thank you.
I'd like to understand a little of what this bat file does.
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
Does this mean the first time through %minimized% will always equal null so it will goto minimized every time?
Will it ever get to the set minimized=true statement? How?
If it does get to the set minimized=true statement it seems to me it should call this bat file with the /min on the start.
Unless the batch is run from a command prompt with %minimized% variable
defined, it will always run this section to define the variable and then
restart the batch in a new minimized process with the variable defined.
But since the original process will have already been displayed before
restarting the batch, there is not much point in doing this.

As you mentioned, you found it on the internet so only the the author
knows why they wrote this code. All you really need is the second start
command with /min inserted.

@echo off
:: This will start a VirtualBox guest minimized
@start /min /wait /b C:\Programs\VirtualBox\VirtualBox.exe --startvm
"c2f7cf76-be3e-496f-8e77-f2823e65c5bd" /SEPARATE/N

Note, unless you have the batch doing other important stuff, you could
just create a shortcut which is set to open VirtualBox minimized instead
of using a batch file.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
Florin Cocy
2022-12-16 02:51:21 UTC
Permalink
Post by Todd Vargo
That worked very nicely. Thank you.
I'd like to understand a little of what this bat file does.
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
Does this mean the first time through %minimized% will always equal null so it will goto minimized every time?
Will it ever get to the set minimized=true statement? How?
If it does get to the set minimized=true statement it seems to me it should call this bat file with the /min on the start.
Unless the batch is run from a command prompt with %minimized% variable
defined, it will always run this section to define the variable and then
restart the batch in a new minimized process with the variable defined.
But since the original process will have already been displayed before
restarting the batch, there is not much point in doing this.
As you mentioned, you found it on the internet so only the the author
knows why they wrote this code. All you really need is the second start
command with /min inserted.
@echo off
:: This will start a VirtualBox guest minimized
@start /min /wait /b C:\Programs\VirtualBox\VirtualBox.exe --startvm
"c2f7cf76-be3e-496f-8e77-f2823e65c5bd" /SEPARATE/N
Note, unless you have the batch doing other important stuff, you could
just create a shortcut which is set to open VirtualBox minimized instead
of using a batch file.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
On Linux :



First, make sure that the Virtual Box binaries are in your path. This is done by default on Linux, but in Windows, you might have to manually add the installation directory's bin folder to your path.

Then, you need to know either your Guest OS name or UUID number. You can find both of these by typing

VBoxManage list vms

into a terminal. From there, simply type

VBoxHeadless -s <Guest-OS-Name>

or

VBoxHeadless -s <UUID>

This launches the VM without attaching its display to a window. Now all you have to do is set this command as a boot-time service that runs in the background, and you'll be set.
Share
Improve this answer
Follow
answered Nov 19, 2009 at 3:09
Mies's user avatar
Mies
70166 silver badges44 bronze badges

4
Is there a way to add this as a parameter (or something) to the machines settings? – 
MrGlass
Aug 15, 2012 at 16:30

Add a comment
93

Old question, but an update is in order:

As of VirtualBox 4.2, you can start a headless machine from the GUI by holding Shift while you click the Start button.

Horribly unintuitive, but that, and other new features, are outlined in an Oracle blog post.

EDIT: As of VirtualBox 5.0, there's a dropdown on the Start button that allows you to choose how to start the VM, including in headless mode.
Share
Improve this answer
Follow
edited Jun 13, 2016 at 20:36
answered Jan 7, 2013 at 0:31
Tarka's user avatar
Tarka
1,57511 gold badge1111 silver badges1010 bronze badges

4
How to open the window after I start a headless machine ? – 
wener
Apr 10, 2014 at 1:21
3
In VirtualBox 5.0, there is a drop down arrow next to the start button. Using that, you can select between a normal, headless, or detachable start. – 
Bastian35022
Nov 13, 2015 at 8:50

Add a comment
19

You can tell VirtualBox to start the VM in headless mode, not using the gui start button - but its the same.

VBoxManage startvm <guest-os-name> --type headless

Loading...