Menu

Using vmrun to control virtual machines in VMware Workstation

I’m working on scripting a shutdown/logoff script for my host machine that will suspend any running virtual machines as the host powers off, then restart them when the host restarts (or when a specific user logs in).

VMware provides a hand command line utility, vmrun, to send commands to VMware Workstation or VMware Server. The power options are:

start – Powers on a virtual machine. The virtual machine may be started without a VMware user interface by passing the nogui parameter.

stop – Powers off a virtual machine. The guest OS can be made aware of the shutdown by passing the soft parameter, or the power can be abruptly cut by passing the hard parameter.

reset – Restarts a virtual machine. The guest OS can be made aware of the restart by passing the soft parameter, or the power can be abruptly cut by passing the hard parameter.

suspend – Suspends a virtual machine. The guest OS can be made aware of the suspend command by passing the soft parameter, allowing it to sleep/hibernate (if supported).

pause – Pauses a virtual machine.

unpause – Resumes a paused virtual machine.

For power commands that support the soft parameter, specifying soft sends instructions to the guest OS to allow it to gracefully power down, sleep, hibernate, etc. This also allows scripts to run in VMware Tools, or in the guest OS itself.

The pause and unpause commands are instructions to VMware Workstation or VMware Server and are invisible to the guest OS.