VMware {code}

 View Only
  • 1.  Using APIs to run scripts inside VMs

    Posted Oct 13, 2010 10:52 PM

    I have a batch file and some vbscript that I would like to run inside the operating system of a number of VMs. Can I use the VMware APIs to access a virtual machine, and make this code run inside the VM?

    For example, say I want to run two simple commands from an MSDOS batch file command inside a Windows VM like:

    echo Setting Password...

    net user testUser passw0rd

    Can I use VMware APIs to access this VM and run these MSDOS batch file commands? I have a number of batch file commands and VBScripts as well that I would like to run.

    Thanks for your input



  • 2.  Re: Using APIs to run scripts inside VMs

    Broadcom Employee
    Posted Oct 14, 2010 03:23 AM

    Yep! You can use VMware VIX which is an API for guest management which also allows you to execute a specific command or script within the guest. Check out the documentation and further details here - http://www.vmware.com/support/developer/vix-api/

    =========================================================================

    William Lam

    VMware vExpert 2009,2010

    VMware scripts and resources at:

    Twitter: @lamw

    Getting Started with the vMA (tips/tricks)

    Getting Started with the vSphere SDK for Perl

    VMware Code Central - Scripts/Sample code for Developers and Administrators

    VMware Developer Community

    If you find this information useful, please award points for "correct" or "helpful".



  • 3.  Re: Using APIs to run scripts inside VMs

    Posted Oct 15, 2010 11:36 PM

    OK thanks. Am I correct in understanding that you can't run MSDOS batch files or Java with it though - only C, Perl, and visualbasic.net/vbscript. Is that correct? Is there a way to run just basic MSDOS commands or Java?



  • 4.  Re: Using APIs to run scripts inside VMs

    Broadcom Employee
    Posted Oct 16, 2010 12:13 AM

    It can run whatever script you can run within the guestOS, so if you have a Java interpreter, then you just need to specify the path and the .java file.

    I would recommend creating a script that does the actual execution, test it out manually and then once you have that done. You can either store the script from where ever you're running the VIX call OR have it on the guestOS and just have VIX execute the script. I would recommend taking a look at the documentation for some examples.

    =========================================================================

    William Lam

    VMware vExpert 2009,2010

    VMware VCP3,4

    VMware VCAP-DCA4

    VMware scripts and resources at:

    Twitter: @lamw

    Getting Started with the vMA (tips/tricks)

    Getting Started with the vSphere SDK for Perl

    VMware Code Central - Scripts/Sample code for Developers and Administrators

    VMware Developer Community

    If you find this information useful, please award points for "correct" or "helpful".