Posted by: Rick Vanover
Rick Vanover, Virtualization, VMware, VMware Workstation
Having a virtual machine or series of virtual machines start up from a script or remote command can be a time saver, especially when compared with logging into the Web interface. VMware Server 2 and prior versions offer the vmrun command for six major tasks that you can perform on a virtual machine: starting, stopping, resetting, pausing, unpausing and suspending. Let’s run through an example that I recently saved as scripts on my VMware Server 2 (build 116503) installed on a Linux server.
The following command will start the virtual machine named ScriptStart1:
vmrun -T server -h https://dhcp-122:8333/sdk -u root -p rootpass start "[standard] ScripitStartVM1/ScriptStartVM1.vmx"
Once that command is launched, the receipt of this command is represented in the scrolling log accessible through VMware Server Web Access. This is shown in the figure below:
One important note that in this example the command is case sensitive to the datastore path, so the VM name of ScriptStart1 cannot be represented any way other than its location in the datastore. The path and .vmx file name may vary in situations where the VM has undergone name changes or copy operations from another VM.
There are quite a lot of parameters passed to the VMware server with the vmrun command, and it is important to note a few attributes of the command. The parameters are designated below:
- T – VMware platform, server is the designation for VMware Server
- h – This URL is the host system. Note the port assignment will be set during installation. This example was a default configuration
- u -p – username and password sent to the host
- start – the command sent to the host
The last parameter is the path to the virtual machine within the datastore.
Aside from this quick example of a basic start command, vmrun has many other features, such as installing VMware Tools, adding shared folders, killing a process in a guest VM and reverting to a snapshot. One positive point about vmrun is that it can be used in both VMware Server (versions 1 and 2) and VMware Workstation products. There is a lot more to vmrun, and the full command documentation can be found in the vmrun control document available on the VMware website.