Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I start Virtualbox from the command line and start a Ruby script on the guest and after the script is done close the guest? What could be easiest way to do this?

share|improve this question

You can start the VM with VBoxManage:

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm <NameOfVMHere>

After the VM has booted you can run a program if you have guest editions installed:

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" guestcontrol exec --image <path to program> --username <name>  [--password <password>]  [--wait-exit] [--wait-stdout] [--wait-stderr]

Finally, when the program has finished executing you can close the VM with the command:

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm <vm> savestate

Alternatively, you can shutdown the machine with a command at the end of the Ruby Script

share|improve this answer
But how to start ruby script you say: --image path to program, but I want to start ruby.rb like I do in command line ruby ruby.rb – Dakadaka Feb 18 '13 at 16:20
I mean as guest to start in the guest ruby or php – Dakadaka Feb 18 '13 at 16:29
Make a script with the command you normally run and then call the script. – David Feb 19 '13 at 16:35
It gives an error that 'ruby' is not recognized as an internal or external function, even though the ruby executable is in path. – titusfortner Dec 8 '15 at 21:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.