Manage Learn to apply best practices and optimize your operations.

Control VMware Workstation 12 from the command line

It doesn't matter if you're using Windows, Linux or a Mac, you can control VMware Workstation 12 from the command line with the following useful commands.

Most VMware Workstation 12 users never get beyond the functionality provided through the graphical application....

This is understandable, as this application offers sufficient functionality for most users. There are a few command line utilities available as well, though, including the vmrun command.

Two of the most important utilities you can use in VMware Workstation 12 are vmware-vdiskmanager and vmrun. The vmrun utility is a tool that helps users manage VMs from the command line. The vmware-vdiskmanager utility allows administrators to control VMware disk files from the command line. In this article, you'll learn more about the vmrun utility, we will discuss the vmware-vdiskmanager utility in depth in an upcoming article.

If you're using VMware Workstation 12 on a Linux host, consider yourself lucky. Linux provides some additional utilities, including vmware-netcfg, which allows you to configure networking from the command line and vmware-mount, which allows you to mount VMware disk images.

The vmrun command was created as a scripting tool to use on multiple VMware platforms. These include VMware Workstation, Player and Fusion, as well as ESX and ESXi hosts managed by a vCenter server. Vmware-run is available on Windows as well as Linux hosts in VMware Workstation 12 Pro. If you need to manage multiple VMs and automate the execution of tasks within these VMs, you're going to like the vmrun utility. It allows you to both start and stop a VM and provides utilities to run operations directly within the VM.

Using the vmrun utility in VMware Workstation 12

The vmrun utility is easily accessible from a Linux host; just type the vmrun command to see which options it proposes. On Windows and Mac computers, you can find the utility in the directory where VMware Workstation is installed. On Windows, this is C:\Program Files\VMware\VMwareWorkstation. Modifying the system path to include the VMware Workstation directory makes using vmrun easier. On Mac, you'll find the tool in /Applications/VMware\ Fusion.app/Contents/Library.

To get an overview of the options that vmrun offers, just type the vmrun command; it shows the many things that can be done. First, you'll need to make clear which host platform vmrun has to contact. For instance, use vmrun -T ws start "c:\my VMs\thisvm.vmx" to start a VM in VMware Workstation on Windows. The -T option allows you to specify the target platform, which can be Workstation, Fusion, ESX and even the legacy VMware server product. Even when using vmrun locally, you'll always need to use the -T option to specify the target platform.

After identifying the target platform, you can specify the operation you'd like to run. You can use any of the following power commands: start, stop, reset, suspend, pause and unpause. These allow you to run a VM, stop it and perform some other generic options. Next, there are the snapshot commands that allow you to run snapshot operations, such as snapshot, which creates a snapshot; listSnapshots, which provides a list of all current snapshots; and revertToSnapshot, which allows you to revert to a previous snapshot state.

The most interesting commands that you can use are guest OS commands, which, as their name implies, allow you to interact directly with the guest OS. There's one condition though: VMware Tools must be installed within the guest OS. If this is the case, you can use commands such as runProgramInGuest, listProcessesInGuest, killProcessInGuest, copyFileFromHostToGuest and many more -- refer to the command help output for a complete list.

When running commands in a locally installed OS, you'll need to specify authentication credentials for the local OS as well. These can be provided using the -gu -- guest user -- and -gp -- guest password -- options. The result can be a command that looks as follows:

vmrun -T ws -gu root -gp password runProgramInGuest "c:\my VMs\linux.vmx" "systemctl start httpd".

This command would address VMware Workstation -- -T ws -- running on a Windows host, which can be seen by the full path name of the VM. The user name root and password "password" are used to authenticate the guest, and will execute the command systemctl start httpd.

The vmrun tool allows you to run automated tasks on and in one or many VMs, which makes it a perfect test for administrators who need to interact with many VMs simultaneously.

Next Steps

Tips for sharing VMs in VMware Workstation 12

Inside the top VMware Workstation features

The best Linux commands for server admins

This was last published in October 2016

Dig Deeper on VMware Workstation, Fusion and Player

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

What do you think are the most useful commands for VMware Workstation 12?
Cancel

-ADS BY GOOGLE

SearchServerVirtualization

SearchVirtualDesktop

SearchDataCenter

SearchCloudComputing

Close