VMWare Script to Toggle VMWare Workstation start/suspend

May 14, 2013 linux scripting
This post is more than 18 months old. Since technology changes too rapidly, this content may be out of date (but that's not always the case). Please remember to verify any technical or programming information with the current release.

Normally I have multiple vm’s running for various different projects - all of these are in VMWare Workstation instances I toggle between suspend and started. I decided to create a script and an Ubuntu launcher icon for toggling the vms back and forth.

First, check out the launcher I used:

[Desktop Entry]
Name=VMWare MyProject Toggle
GenericName=VMWare MyProject Toggle
Comment=Run VMWare

The bash toggle script checks to see if the current VM is running, and then does the appropriate action depending on if it was found or not.


RUNNING=`vmrun list`

if [[ "$RUNNING" == *"$VM"* ]]
  vmrun suspend "$VM" soft
  vmrun start "$VM"

So, when I start my day, all I have to do is type the name of my project and hit enter on the launcher. When the day is done, no need to find the VM’s small X on the tab - I just run the toggle again and its suspended.

Go to All Posts