Home » Web Development » Auto Start / Shutdown a Virtual Box Machine via Command line aka CLI

Auto Start / Shutdown a Virtual Box Machine via Command line aka CLI

I had a Virtual box machine which would be needed to start and shutdown every day at work. So one day, I decided to do something about it. Googled a bit and finally found a small interim solution to it.

First off, open a command prompt and enter the following.

cd %PROGRAMFILES%/oracle/virtualbox

The following are the commands to discover the Virtual VM Management.

cd %PROGRAMFILES%/oracle/virtualbox
VBoxManage list vms
vboxmanage startvm "VMName"
vboxmanage controlvm "VMName" poweroff
vboxmanage controlvm "VMName" pause
controlvm "VMName" acpipowerbutton 

The first command will change directory to Program file > Oracle > and finally to Virtual Box Directory. After that, VboxManage list the VMs currently registered on parent machine with their names reffered to as VMName in the commands below.

Once the name is finalized, All one has to do is to issue the command to power up. For powering up, the command is StartVM followed by VMName.

For shutting down a VM, the command would be vboxmanage controlvm “VMName” poweroff

With this knowledge, all one has to do is to make two batch files, aka, Startup.bat and ShutDown.bat. The following are the source code of those files.

Source code of Startup.bat

cd %PROGRAMFILES%/oracle/virtualbox
vboxmanage startvm "VMName"

Source code of Shutdown.bat

cd %PROGRAMFILES%/oracle/virtualbox
vboxmanage controlvm "VMName" poweroff

And now, assign these batch files to Startup events of Windows and shutdown events of Windows. Now these VMs doesn’t need to be started everyday. They will be started and shutdown whenever, their parent machines are switched on and off.

The following links will provide more detailed information on the topic.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s