$err = VMDelete($vmHandle,
This function permanently deletes a virtual machine from your host system.
Identifies a virtual machine. Call VMOpen() to create a virtual machine handle.
For VMware Server 2.0 and ESX, this value must be VIX_VMDELETE_DISK_FILES.
For all other versions it can be either 0 or VIX_VMDELETE_DISK_FILES.
When option is VIX_VMDELETE_DISK_FILES, deletes all associated files.
When option is 0, does not delete *.vmdk virtual disk file(s).
$err. The error code returned by the operation. For returned values, see Topics > Error Codes.
- This function permanently deletes a virtual machine from your host system.
You can accomplish the same effect by deleting all virtual machine files
using the host file system. This function simplifies the task by deleting
all VMware files in a single function call. If a deleteOptions value of 0
is specified, the virtual disk (vmdk) files will not be deleted.
This function does not delete other user files in the virtual machine folder.
- This function is successful only if the virtual machine is powered off
- Deleting a virtual machine that is the parent of a linked clone renders
the linked clone useless.
- Calling VMDelete() on a virtual machine handle does not release the
virtual machine handle. You still need to call ReleaseHandle() on the
virtual machine handle.
since VMware Server 1.0
my $err = VIX_OK;
my $hostHandle = VIX_INVALID_HANDLE;
my $vmHandle = VIX_INVALID_HANDLE;
($err, $hostHandle) = HostConnect(VIX_API_VERSION,
undef, # hostName
0, # hostPort
undef, # userName
undef, # password
0, # options
VIX_INVALID_HANDLE); # propertyListHandle
die "HostConnect() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;
($err, $vmHandle) = VMOpen($hostHandle,
die "VMOpen() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;
$err = VMDelete($vmHandle, VIX_VMDELETE_DISK_FILES);
die "VMDelete() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;