Error DataBase-One Place all Solutions Forums Blog Glossary    Contact Us
Search  
   
Browse by Category
Error DataBase-One Place all Solutions .: Virtualization .: Script the Startup and Shutdown of VMware Servers

Script the Startup and Shutdown of VMware Servers

In using VMware Server, sooner or later you will have a need to script the startup and shutdown of VMware Servers. You may want to do this for backup purposes or just to be able to run a script that can quickly stop or start virtual servers without bring up the VMware administrative application. Let's find out how to do this...

The vmware-cmd Command

Located in the default install directory of VMware Server is the VMware Server directory. Normally, this is in:

C:\Program Files\VMware\VMware Server

In this directory you'll see vmware-cmd. This is a command line utility that can perform all types of command line VMware functions. For example, get the state of a server, stop a server, start a server, reset & suspend servers, and a long list of other functions. Here is the command line help information for vmware-cmd:

Also, here is the output in text format:

vmware-cmd help info

Starting up Servers with vmware-cmd

A common use for the vmware-cmd CLI tool is to start and stop virtual servers. You can do this by manually typing the required information at the command line or you can write a BAT (batch) file that can script this for you. If you think that you may do this more than once, writing a batch file is the best way to go because it doesn't take much more effort beyond entering the commands at the CLI and it can be run again and again. Also, the batch file is a great way to go because the required parameter to use vmware-cmd is the exact patch to the VMX file for the virtual machine being started/stopped and this path can be very long.

What I have done is used notepad to write a batch file to start my two virtual machines. The syntax looks like this:

vmware-cmd {exact path to VMX file} start

Note that you must be in the path where the vmware-cmd program is or your script must provide the exact path. This is why I do a cd to the proper directory before running the command.

This is done for each virtual machine.

Here is a sample script that you can open, download, and modify for your own needs.

C:
cd "\Program Files\VMWare\VMware Server"
call vmware-cmd "C:\Virtual Machines\Win2000Pro\Windows 2000 Professional.vmx" stop
call vmware-cmd "C:\Virtual Machines\WinXP\Windows XP Professional.vmx" stop
cd \

Copy these command in notepad and save it as ***.Bat file and run the batch file

Here is what it looks like when it is run.

An output of "start() = 1" means that the start was a success. As long as the virtual machines are already stopped, you shouldn't have any trouble starting them up.

Shutting down Servers with vmware-cmd

With the VMware Guest OSs started, I copied my batch file called startvms.bat and renamed it stopvms.bat. Then, I used notepad to replace the word start with stop.  The syntax looks like this:

vmware-cmd {exact path to VMX file} stop

This is done for each virtual machine.


How helpful was this article to you?

Related Articles

article How to Remotely Manage your VMware Servers
As soon as you begin using VMware Servers...

(No rating)  4-14-2008    Views: 210   
article Why do you Virtualize your servers with VMware Server
Virtualization is becoming more and more...

(No rating)  4-13-2008    Views: 167   
article How To Troubleshoot Shutdown Problems in Windows Server 2003
SUMMARY How to Troubleshoot Shutdown...

(No rating)  7-8-2008    Views: 110   

User Comments

Add Comment
No comments have been posted.