How can I run VBOX under WIN like a service with script?
The trick is to run the VM without GUI. With this you can easily run VM on WIN server like a service too.
Prerequired is that exist some VM, you have some already. Below put its name instead {vm_name}.
1) Create script BAT
Use build-in executable file “VBoxHeadless.exe”.
Create file
vm.run.bat
with
cd "c:\Program Files\Oracle\VirtualBox\"
VBoxHeadless.exe -s {vm_name} -v on
run and test it – with WIN “Command Line Interface (CLI)” called “Command shell” – and VM will be opened running in background.
vm.run.bat
2) Create script VBS
Use “Windows-based script host (WSCRIPT)” and language “Microsoft Visual Basic Script (VBS)” and run above file “vm.run.bat”.
Create file
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
Ref
- Thanks to iain