Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using VirtualBox on Windows.

Is there a way to make a script that will close the VM and "save the state"? Or even just tell the VM to shutdown?

Non-sequitur:

  • I know you can open the VM from the command line because I have a shortcut to open the VM. And so I can just call the shortcut from the command lien.
  • The reason I ask is because my backup software has a pre-backup/post-backup command line option. So I would like to use the command line to save the state of the VM. Then backup the VM. Then use the command line to start the VM.
share|improve this question
    
I created two batch file scripts each with one line. The "pre" batch file saves the sate of the VM. Then the backup copies the VM files. Then the "Post" batch file restores the VM. –  Trevor Boyd Smith Aug 1 '11 at 14:56

1 Answer 1

up vote 5 down vote accepted

From the VBoxManage manual:

VBoxManage controlvm <vm> savestate will save the current state of the VM to disk and then stop the VM. (This is equivalent to selecting the "Close" item in the "Machine" menu of the GUI or pressing the window's close button, and then selecting "Save the machine state" in the dialog.)

Then you can start again using VBoxManage startvm "Windows XP" (assuming your VM is named "Windows XP" of course).

You should find the VBoxManage.exe somewhere in your VirtualBox installation folder. Of course you can add it to your PATH to have easier access.

share|improve this answer
    
As usual virtual box has great command line support. Huzzah! –  Trevor Boyd Smith Aug 1 '11 at 14:55

Your Answer

 
discard

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.