VMware Communities
Joe_Mosley
Contributor
Contributor

Is there a way to remove a VM programatically either via API or utility i.e. vmrun

I have a rather nice little testing setup whereby i spin up a machine automatically, register it in WS Pro 12.5, deploy my code, test it and then shutdown the box. But i cannot work out how to remove the VM afterwards. From what ive read or seen there is no functionality to do this with WS Pro.

It would be nice to do, i paid for the WS Pro because i was having major issues with VirtualBox but it would appear that they have a much more mature product in terms of automation. Is this the case? Am i just missing something obvious. I can create / test / destroy 50 machines in a day if im testing puppet so i would really rather not have to delete 50 machines through the gui if i can avoid it.

I tried using Shared VMs but i had to a) hack the 12.5 install to use the WS Pro 11 libraries to allow vmrun to work with Shared VMs and b) i cant see how to create SharedVMs via automation either.

0 Kudos
3 Replies
huxiang
Enthusiast
Enthusiast

Hello,

Welcome to Workstation Community!

I just have a try with vmrun, it has a "deleteVM" sub-command. I can use it to delete a VM which is not opened in Workstation Pro. But the problem is, the VM still exists in VM Library of Workstation Pro, you have to remove it manually.

So to delete a VM folder completely from host disk, you can use vmrun or host OS shell command.

And to delete a VM from VM Library... there's no good way to complete it except UI automation. I have a workaround here:

1. You can backup the VM Library configuration file before creating the huge amount of testing VMs

2. After you deleted the testing VM folders, you can close Workstation Pro and restore the VM Library configuration file

VM Library configuration file location

Windows host - %PROGRAMDATA%\VMware\inventory.vmls

Linux Host - ~/.vmware/inventory.vmls

Hope it helps.

Regards,

Shawn

0 Kudos
continuum
Immortal
Immortal

The recent WS-versions dont work with vmrun as expected.
Using 12.01 for example the "deleteVM" function appears to be an invalid option.
Shawn - do you know if 12.5.1 is a "serious" version ? - dont want to risk my current 12.0.1 setup which still works quite acceptable.
Ulli


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

0 Kudos
huxiang
Enthusiast
Enthusiast

Hi Ulli,

I'm sorry for the vmrun related issues you met. We resolved 2 vmrun related issues in 12.1.0 and 12.5.1, please refer to the release notes:

VMware Workstation 12 Pro Version 12.1 Release Notes

VMware Workstation 12 Pro Version 12.5.1 Release Notes

I just tried vmrun in Workstation 12.0.1 with "deleteVM" option on my Windows 10 testing machine, it works well. Not sure what problem did you meet.

Yes, we release every version seriously. 12.5.1 is a patch release, it resolves some issues with new OSes, known issues of previous releases and 12.5.0 new issues reported by customers.

Regards,

Shawn

0 Kudos