Start several VMs at the same time.

This is for discussing general topics about how to use VirtualBox.
Post Reply
sct_nicolaus
Posts: 5
Joined: 18. May 2009, 23:02
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: WindowsXP, Ubuntu

Start several VMs at the same time.

Post by sct_nicolaus »

Hi. Im looking for a smart method to start all my VMs at the same time.

I got X number of VMs, all with Windows XP guests, and all named WinXP1, WinXP2, WinXP3, ... , WinXPX.

Right now i've made a batchfile like this:

vboxmanage startvm "WinXP1"
vboxmanage startvm "WinXP2"
vboxmanage startvm "WinXP3"
...
vboxmanage startvm "WinXPX"

My X can increase and decrease. Right now i got to edit my batch file everytime that happens.

Is there a smart command i can use, like a loop or something, so i don't have to edit every time?

Thx
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Start several VMs at the same time.

Post by Sasquatch »

I'm sure you can. You have to check a folder and read it's contents for example. You can do a count on the amount of folders it has, or files. Or even read the names of the folders which you can put in a variable and use that to pass to the startvm parameter. This idea can be found on countless sites, if you search properly. The trick is the "for" loop. E.g. "for x in $var; do <command>; x + 1". Something like that.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
sct_nicolaus
Posts: 5
Joined: 18. May 2009, 23:02
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: WindowsXP, Ubuntu

Re: Start several VMs at the same time.

Post by sct_nicolaus »

I've just tried this:

----
echo off
SET /P amount= How many VMs?

FOR /L ?? IN (1,1,%amount%) DO "vboxmanage startvm "WinXP%number%"
----

where %number% is the current VM it gotta start.
the (1,1,%amount%) will make it run from 1 to %amount%, with an increment of 1.

The trick is to tell which number I'm at. Also, I dont really know what that first variable does where i wrote ??.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Start several VMs at the same time.

Post by Sasquatch »

I'm sure you can find some tutorials for scripting in Windows that tell you exactly where to put what. Even the MS site has some examples (check their MSDN site).
It's more fun if you figure it out on your own than when someone makes a script for you. You can do so much more that way :). I've already given you a gentle push in the right direction. Good luck.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
sct_nicolaus
Posts: 5
Joined: 18. May 2009, 23:02
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: WindowsXP, Ubuntu

Re: Start several VMs at the same time.

Post by sct_nicolaus »

Hehe, fair enough. Thanks ;)
Post Reply