Name

RemoveSnapshot

Description


This function deletes all saved states for the specified snapshot.

Parameters

snapshot
An ISnapshot object representing the snapshot to remove. A virtual machine's snapshots can be accessed through VM::GetRootSnapshot()
options
Flags to specify optional behavior. Any combination of the following or 0:
jobDoneCallback
An ICallback instance that will be called when the operation is complete.
removeJob
Returns an IJob object that describes the state of this asynchronous operation.

Return Value

HRESULT

Remarks

Side Effects

None.

Requirements

VixCOM.h, since VMware Workstation 6.0

Example

This example deletes every root snapshot belonging to a virtual machine.
Dim lib
Dim host
Dim vm
Dim job
Dim err
Dim results

results = Nothing

Set lib = CreateObject("VixCOM.VixLib")

Set job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION, Empty, 0, Empty, Empty, 0, Nothing, Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT), result)
If lib.ErrorIndicatesFailure(err) Then
   ' Handle error...
End If

Set host = results(0)

Set job = host.OpenVM("c:\Virtual Machines\vm1\win2000.vmx", Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT), result)
If lib.ErrorIndicatesFailure(err) Then
   ' Handle error...
End If

Set vm = results(0)

Dim numSnapshots

err = vm.GetNumRootSnapshots(numSnapshots)
If lib.ErrorIndicatesFailure(err) Then
   ' Handle error...
End If

Dim snapshot

For i=0 to numSnapshots-1
   err = vm.GetRootSnapshot(i, snapshot)
   If lib.ErrorIndicatesFailure(err) Then
      ' Handle error...
   End If
   
   Set job = vm.RemoveSnapshot(snapshot, 0, Nothing)
   err = job.WaitWithoutResults()
   If lib.ErrorIndicatesFailure(err) Then
      ' Handle error...
   End If
Next

Set snapshot = Nothing
Set results = Nothing
Set job = Nothing
Set vm = Nothing

host.Disconnect()

Copyright (C) 2007-2010 VMware, Inc. All rights reserved.