How to run "Oracle VirtualBox (VBOX)" like a service after boot in fully background "Microsoft Windows (WIN)"?
SOLUTION
The trick is to run the VM without GUI. With this you can easily run VM on WIN server like a service too.
0) Prerequired is that exist some VM, you have some already. Below put its name instead {vm_name}.
1) At first we use build-in executable file "VBoxHeadless.exe".
vm.run.bat
put code
cd "c:\Program Files\Oracle\VirtualBox\"
VBoxHeadless.exe -s {vm_name} -v on
run and test it - WIN "Command Line Interface (CLI)" called "Command shell" will be open and VM will running in background.
vm.run.bat
2) Then we use "Windows-based script host (WSCRIPT)" and language "Microsoft Visual Basic Script (VBS)" and run above file "vm.run.bat" with.
vm.run.vbs
put code
Set WshShell = WScript.CreateObject("WScript.Shell")
obj = WshShell.Run("vm.run.bat", 0)
set WshShell = Nothing
run and test it - CLI will be run in background.
wscript.exe vm.run.vbs
REFERENCES
Thanks to iain
http://web.archive.org/web/20150407100735/http://www.techques.com/question/2-188105/Virtualbox-Start-VM-Headless-on-Windows
You can use VBoxManage to start a VM headless:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "Your VM name" --type headless
I used something similar to Samuel's solution that works great.
On the desktop (or any folder), right click and go to New->Shortcut.
In the target, type:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm {uuid} --type headless
In the name, type whatever you want and click Finish.
Then to stop the same vm, create a new shortcut with the target being:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm {uuid} poweroff
Double clicking these starts and stops the VM without any window staying open.