views:

940

answers:

4

Hi,

I am using VMware Workstation 6.5 on Windows Vista x64. I would like to automate some of the VM management tasks. I know that there is a COM API (http://www.vmware.com/support/developer/vix-api/) available which I could use directly.

Is there a C# wrapper for this COM API?

Thanks,

Arnie

+1  A: 

How 'bout adding a reference to this API in your VS.Net and let VS.Net create a managed wrapper for you? I'm not aware of any "managed" API for this. Let me know if you find it :)

Vyas Bharghava
If I don't find one, I might consider writing one. That would be an interesting project... :)
Arnold Zokas
+2  A: 

ArnieZ.

Any COM DLL can be used from .NET. Adding it as reference in visual studio will generate a DLL called

"YourDll.Interop.dll"

This is a .NET -> COM marshaling library, and will do what you need.

You can also generate this from the command line using tlbimp.exe

Of course, you'll have to keep in mind that you are invoking COM components, and remember to use the .NET Marshaling API to decrease reference counts when you are done using them, otherwise you will cause memory leaks.

I've wrapped the interop implementation in another library that implements IDisposable on its objects so that cleanup is handled automatically before, but if it is a large library, this might not be worth the effort.

FlySwat
+6  A: 

There's now a nice library that wraps this up: http://www.codeproject.com/KB/library/VMWareTasks.aspx

Thank you. Good work!Sadly, I've discovered that VMware Workstation doesn't expose certain management operations that I need (such as creation of VMs and VM teams).I won't be able to reach the level of automation that I want until I upgrade to ESX, :-(
Arnold Zokas
It is very nice indeed. And dblock is the author of said wrapper, and a very helpful person!
Retne
+3  A: 

VMWareTasks is a complete wrapper for VixCOM: http://vmwaretasks.codeplex.com

dblock