Control the VMware VMs from the commandline: vmrun – the successor of vmware-cmd
Posted by jpluimers on 2010/05/19
In the process of upgrading from VMware server 1.0 to 2.0, I found out that vmware-cmd.bat has been replaced by vmrun.exe.
The command-line options are different, and this link explains the vmrun command-line options in detail (well, much better than the vmrun.exe built-in help). The official documentation is available as a PDF.
One of the changes I had to make was from:
set vmwareCmd=”C:\Program Files (x86)\VMware\VMware Server\vmware-cmd.bat”
to
set vmwareCmd=”C:\Program Files (x86)\VMware\VMware Server\vmrun.exe” -T server -h https://127.0.0.1:8333/sdk -u Administrator -p mypassword
Now you need to specify the URL to the server, and logon information: username and password.
An other major change is the naming of VMs. In VMware server 1.0, it was just the path to the .vmx file:
“C:\path\file.vmx”
In VMware server 2.0 it contains the name of the datastore:
[datastore] path/filename.vmx
This sample batch-file lists the VMs on my server:
“C:\Program Files (x86)\VMware\VMware Server\vmrun.exe” -T server -h https://127.0.0.1:8333/sdk -u Administrator -p mypassword list
Also the order of parameters and the name of the options changed; the command is now before the name of the VM, trysoft is now soft:
call %vmwareCmd% vmname.vmx stop trysoft
new:
call %vmwareCmd% stop vmname.vmx soft
–jeroen
Reference: Controlling VMware Virtual Machines from the Command Line with vmrun – Virtuatopia






Jaap van Duijvenbode said
Hi Jeroen,
You should take a look at the VMWare VIperl SDK. It foresees in many aspects of either configuring VMWare hosts, vcenter, clusters, even complete datacenters.
I have used http://communities.vmware.com/docs/DOC-9842 as a reference for gathering ESX(i) information from a 3rd party appliance in order to provide info to the central management dashboard of that appliance.
Also take a look at : http://www.vmware.com/support/developer/viperltoolkit/viperl40/doc/vsperl_util_index.html
Speak to you soon,
Jaap
jpluimers said
Indeed, you can even install an appliance with the VMware vMA (vSphere Management Assistant) on your server that has all the prerequisites installed.
I’m using that to port my VMs from ESX 3.5 to ESXi 4.1 now.
The vMA appliance is a CentOS (http://en.wikipedia.org/wiki/CentOS) based, whereas ESXi used to be RHEL based, but has gotten slimmer and slimmer.
It now is basically a vmKernel with trimmed down tools like busybox (http://www.busybox.net/) and dropbearmulti (matt.ucc.asn.au/dropbear/dropbear.html).
More vMA info (including a link to the appliance install): http://www.vmware.com/support/developer/vima
That page has a tiny lie: it indicates that vi-admin has root privileges, but in fact vi-admin comes close but is not completely root (the root password is unknown, and sudo does not work with all commands).
But vMA is certainly very nice, and has a low footprint.
–jeroen