Using vmrun to Control Virtual Machines VMware Fusion 5 VMware Workstation 9 and Player 5 VMware vSphere 5.x This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new edition. To check for more recent editions of this document, see http://www.vmware.com/support/pubs.
Using vmrun to Control Virtual Machines You can find the most up-to-date technical documentation on the VMware Web site at: http://www.vmware.com/support/ The VMware Web site also provides the latest product updates. If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com Copyright © 2008–2012 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws.
Contents About This Book 5 Using vmrun to Control Virtual Machines 7 About the vmrun Utility 7 Power Commands 7 Snapshot Commands 7 Guest Operating System Commands 7 Maintenance Commands 8 VProbes Commands 8 Limitations 8 Setting Up vmrun 8 How to Get vmrun 8 Linux Setup 8 Windows Setup 9 Mac OS X Setup 9 Specifying the VMware Product Platform 9 Encrypted Virtual Machines 9 Guest Operations 9 Running Hosted Platforms Locally 9 Running VMware vSphere Remotely 10 Running VMware Server Remotely 10 Virtual
Using vmrun to Control Virtual Machines 4 VMware, Inc.
About This Book This manual, Using vmrun to Control Virtual Machines, documents the vmrun utility, which helps you manage a collection of virtual machines on a VMware® host. Revision History This book is revised with each release of the product or when necessary. A revised version can contain minor or major changes. Table 1 summarizes the significant changes in each version of this guide. Table 1. Revision History Revision Description 2012‐10‐04 For the VIX API 1.12 release.
Using vmrun to Control Virtual Machines 6 VMware, Inc.
l Using vmrun to Control Virtual Machines This document contains the following sections: “About the vmrun Utility” on page 7 “Setting Up vmrun” on page 8 “Specifying the VMware Product Platform” on page 9 “Virtual Machine Run Reference” on page 10 “Examples of Using vmrun” on page 15 About the vmrun Utility You can use the vmrun command‐line utility to control virtual machines and automate guest operations on VMware virtual machines.
Using vmrun to Control Virtual Machines Check if a file or directory exists in the guest, delete a file or directory, rename a file, list files, or create a new directory. Copy a file from the host to the guest, or from the guest to the host. Create a temporary file in the guest operating system. Add a shared folder from the host, make a shared folder writable in the guest, or remove a shared folder. Capture a screen image from the guest (Workstation and VMware Fusion only).
Using vmrun to Control Virtual Machines Windows Setup To use the vmrun utility on Windows 1 If you are running VMware Workstation, a copy of vmrun is included in the folder where you installed Workstation. If you install the VIX API, a possibly newer vmrun is placed in one of these folders: 32‐bit systems – C:\Program Files\VMware\VMware VIX 64‐bit systems – C:\Program Files (x86)\VMware\VMware VIX 2 (Optional) Most users find it convenient to add the vmrun install location, either VMware Workstation or
Using vmrun to Control Virtual Machines NOTE On VMware Fusion, Workstation, and Player, powering on a virtual machine with the default gui option requires a window system (user interface) to be running on the host. ESX/ESXi hosts, vCenter Server, and VMware Server (discontinued) do not impose this requirement. Running VMware vSphere Remotely In VMware vSphere, use the -T flag to connect to an ESX/ESXi host or to the vCenter Server.
Using vmrun to Control Virtual Machines Disabling Dialog Boxes With virtual machines that require user input through a dialog box, the vmrun utility might time out and fail. To disable dialog boxes, insert the following line in the virtual machine configuration file (.vmx): msg.autoAnswer = TRUE Syntax of vmrun Commands Table 2 lists vmrun commands and parameters according to their function. Parameters are listed one per line. Parameters enclosed in square brackets are optional.
Using vmrun to Control Virtual Machines Table 2. vmrun Commands and Parameters (Continued) Command Description Parameters deleteSnapshot Removes a snapshot from a virtual machine (.vmx file). For products that support multiple snapshots, you must provide the snapshot name. (VMware Server always deletes the root snapshot.) [ andDeleteChildren ] The virtual machine must be powered off or suspended.
Using vmrun to Control Virtual Machines Table 2. vmrun Commands and Parameters (Continued) Command Description Parameters renameFileInGuest Renames or moves a file in the guest operating system. VMware Tools and a valid guest login are required. Specify the source name (original) before the destination (new). Deletes the give file from the guest operating system. VMware Tools and a valid guest login are required.
Using vmrun to Control Virtual Machines Table 2. vmrun Commands and Parameters (Continued) Command Description Parameters removeSharedFolder Removes the guest virtual machine’s access to a shared folder on the host. The share name is a mount point in the guest file system. (VMware vSphere and VMware Server do not support shared folders.) setSharedFolderState (VMware vSphere and VMware Server do not support shared folders.
Using vmrun to Control Virtual Machines Table 2. vmrun Commands and Parameters (Continued) Command Description Parameters clone Creates a copy of the virtual machine and guest. Provide both the source and the destination .vmx file pathname. You can create either a full clone or a linked clone. To create the clone from a snapshot, rather than from the current virtual machine state, specify a snapshot name. (Cloning not supported on VMware Server or on VMware Fusion.
Using vmrun to Control Virtual Machines vmrun -T esx -h 10.0.1.8 -u root -p start "[datastore1] WinXP/WinXP.vmx" If HTTPS service is not configured on port 443, specify the appropriate port after the colon: vmrun -T esx -h 10.0.1.9:8333 -u root -p start "[datastore1] WinXP/WinXP.vmx" On the remote ESX/ESXi host with IP address 10.0.1.8, power off the virtual machine: vmrun -T esx -h 10.0.1.8 -u root -p start "[datastore1] WinXP/WinXP.
Using vmrun to Control Virtual Machines For commands that require an environment variable, you can set it first, or export it for multiple commands: vmrun -gu -gp runProgramInGuest SUSE/SUSE.vmx "DISPLAY=:0 /usr/bin/salesgui" vmrun -gu -gp runProgramInGuest SUSE/SUSE.
Using vmrun to Control Virtual Machines vmrun Guest Guest vmrun Guest Guest writeVariable Ubuntu10/Ubuntu10.vmx guestEnv LD_LIBRARY_PATH /usr/local/lib user: root password: runScriptInGuest Ubuntu10/Ubuntu10.vmx /bin/bash "usr/bin/env > /tmp/env.out" user: root password: No output comes to the host from runScriptInGuest, so look at /tmp/env.out on the guest. On a Linux guest, determine the IP address and set it in a guest variable: $ ipaddr=‘ifconfig eth0 | grep inet.
Index A readVariable 14 removeSharedFolder 14 renameFileInGuest 13 runProgramInGuest 12 runScriptInGuest 12 setSharedFolderState 14 user name and password 9 writeVariable 14 addSharedFolder command 13, 17 C captureScreen command 14 clone command 15 command-line flags 9 copyFileFromGuestToHost command 13, 17 copyFileFromHostToGuest command 13, 17 createDirectoryInGuest command 13 createTempFileInGuest command 13 I installTools command 14, 18 D K deleteDirectoryInGuest command 13 deleteFileInGuest com
Using vmrun to Control Virtual Machines R record and replay commands 8 register command 14, 18 removeSharedFolder command 14, 17 renameFileInGuest command 13 reset command 11, 15 revertToSnapshot command 12, 16 runProgramInGuest command 12, 16 runScriptInGuest command 12, 16 S Server, flags for 10 setSharedFolderState command 14, 17 setup on Linux 8 setup on Mac OS 9 setup on Windows 9 snapshot command 11, 16 snapshot commands 7 deleteSnapshot 12 listSnapshots 11 revertToSnapshot 12 snapshot 11 start comm