How to Administer VMware Workstation from the Command Line
VMware Workstation and Server both come with the VMware Management Interface (VMI). The VMware Server product also has its web-based administration component. However, sooner or later, you will want to administer VMware from the command line. For example, you may want to write scripts to shutdown VMware virtual servers so that you can run backups on the disk files and, later, start the VMware virtual servers again. This is an example of a task that you could do, all from the command line. Let’s learn how.
Difference between Workstation and Server
There is a difference between administering VMware Workstation and Server from the command line. In VMware Workstation, you use the vmrun command. In VMware Server, you use vmware-run command. In this article, we will discuss how to administer VMware Workstation from the command line and save the vmware-run Server command for a separate article.
Using the vmrun command
The main command-line program used to stop and start VMware Workstation Virtual machines is the vmrun command. If you open the Windows cmd prompt and change directory to C:’Program Files’VMware’VMware Server. Once there, type vmrun and press Enter. Here is an example: You will see the help information for the vmrun command. From this, you can see that it has options like list, start, stop, reset, suspend, and more. Let’s say that we want to list out all running virtual machines. To do this, use the vmrun list command. Here is an example: In this example, you see that there is 1 running virtual machine and you are given the full path to the .vmx file that gives the configuration for this virtual machine. This is very useful for writing a script to stop and start this virtual machine. Copy this full path into your clipboard. Open Wordpad or Notepad and paste this full path into the Wordpad document. Put the full path in double-quotes and add the words vmrun start at the beginning of the line. Next, copy all this text into your clipboard. Now go to the GUI interface and stop this virtual machine and close the GUI interface. Back in your Windows cmd window, paste the text in your clipboard at your Windows cmd prompt and press Enter. Here is an example of successfully starting a virtual machine from the command line: Note that you can stop a VMware machine with the VMware Management Interface up and running. However, if you try to start a VM with the VMI running you will get an error. To start a VM successfully from the command line, you must stop the VMI. Now that your VM is running, try stopping it from the command line. To do this, just push up-arrow and change the start option to stop and press Enter, like this: You can easily save your Wordpad document as a .bat file to make a script out of it. To do this, make sure that you set the document format as a text file and set the extension to .bat, like this: You could then create a shortcut on your desktop so that you could quickly start this virtual machine by clicking a single icon on your desktop. Some other things you can do with the vmrun command are reset a VM, suspend a VM, install vmware tools in the VM, or list/delete/revert Snapshots. Another command line tool you may want to use is the vmware.exe command. If you run the vmware command by itself, you will just start the VMware Management Interface. However, there are some other switches for this command, shown below: It is important to know that the vmware.exe command has different options when using VMware Server.
In summary, the ability to administer VMware Workstation virtual machines from the command line can make using VMware much more convenient. Even more than just convenience, it may be necessary to use scripts to start & stop VMs to perform backups. Also, know that administering VMware from the command line is different in VMware Workstation vs VMware Server.
Got a question? Post it on our VMware Forums!
More in VMware
Azure VMware Solution Gets Support for Stretched Clusters and Customer-Managed Keys
Nov 8, 2022 | Rabia Noureen
VMware to Launch New vCenter Converter Tool in Beta
Sep 14, 2022 | Rabia Noureen
VMware Carbon Black Releases Fix for BSOD and Boot Loop Issues on Windows
Aug 24, 2022 | Rabia Noureen
VMware Releases Updates to Address Critical Authentication Bypass Flaw
Aug 3, 2022 | Rabia Noureen
Big Announcements at AWS re:Invent 2021
Dec 2, 2021 | Michael Otey
Amazon Announces the General Availability of VMware Cloud on AWS Outposts
Oct 12, 2021 | Michael Otey
Most popular on petri