+ Reply to Thread
Results 1 to 2 of 2

Thread: using Vmware SDK

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    36

    using Vmware SDK

    I would like some code snippets showing how to control Vmware using it's sdk.

    Thanks a lot in advance.
    Last edited by cpro; 11-02-2012 at 11:43 AM.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    36
    Using the Library

    In order to use the library or build or run the source code, you must install the following VMWare software.

    VMWare VIX. This is the SDK, obtained from HERE. The new 1.6.2 version is required for VI support.
    Either VMWare Workstation 6.5, a VI environment (I use ESX), or both.
    In your project, add a reference to Vestris.VMWareLib.dll and a namespace reference.
    Code:
    using Vestris.VMWareLib;
    Code:
    // declare a virtual host
    VMWareVirtualHost virtualHost = new VMWareVirtualHost();
    // connect to a local (VMWare Workstation) virtual machine
    virtualHost.ConnectToVMWareWorkstation();
    // open an existing virtual machine
    VMWareVirtualMachine virtualMachine = virtualHost.Open("C:\Virtual Machines\xp\xp.vmx");
    // power on this virtual machine
    virtualMachine.PowerOn();
    // login to the virtual machine
    virtualMachine.Login("Administrator", "password");
    // run notepad
    virtualMachine.RunProgramInGuest("notepad.exe", string.Empty);
    // create a new snapshot
    string name = "New Snapshot";
    // take a snapshot at the current state
    virtualMachine.Snapshots.CreateSnapshot(name, "test snapshot");
    // power off
    virtualMachine.PowerOff();
    // find the newly created snapshot
    VMWareSnapshot snapshot = virtualMachine.Snapshots.GetNamedSnapshot(name);
    // revert to the new snapshot
    snapshot.RevertToSnapshot();
    // delete snapshot
    snapshot.RemoveSnapshot();
    Hope that was a good introduction to the VMWare API in C#.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts