VMware Workstation提供的可编程接口
在Vmware安装目录下能找到一个(默认:C:Program Files (x86)VmwareVmware Workstation) Vmrun.exe可执行文件。如果你从命令行敲入vmrun.exe(当然你得切换到workstation的根目录下),你会发现该命令提供了很多的参数,例如:
Example:
用C#启动到指定的snapshot:(前置:vmware已经打开了)
Process p = new Process(); p.StartInfo.WorkingDirectory = @"C:Program Files (x86)VMwareVMware Workstation"; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "cmd.exe"; //关闭
p.StandardInput.WriteLine("vmrun stop " + ""E:\win 7\CHS_64\CHS win7 64.vmx""); //转到指定的snapshot
p.StandardInput.WriteLine("vmrun -T ws revertToSnapshot " + ""E:\win 7\CHS_64\CHS win7 64.vmx"" + " " + ""1""); //启动
p.StandardInput.WriteLine("vmrun start " + ""E:\win 7\CHS_64\CHS win7 64.vmx"");