The virtual machine (VMware Workstation) is programmed to check some of the content of the official VMware website, but there are still many problems when debugging.
At first I wanted to control the virtual machine through the command line, but there were always some problems and I didn't understand it.
First of all, the green version of the online download is still a lot of features can not be implemented.
Second, the virtual machine version is not the same, and its supported commands are different, the higher the version, the more commands are supported.
I use the VMware Workstation 6.0.3 build-80004, at the command line, can only do (1) Turn on (2) off (3) restart (4) suspend these four features, I want to use the recovery snapshot is not used.
Open: Vmware-x vm.vmx
Close: Vmrun Stop VM.VMX
Restart: Vmrun reset vm.vmx Soft (no soft for direct restart)
Pending: Vmrun suspend VM.VMX
Fortunately, since the 6.0 release of Vix_api, you can directly in their own programs using VIX_API operation of virtual machines, and the functions can be implemented:-)
After the full installation of VMware Workstation 6.0, there will be a VMware VIX folder in the installation directory, which contains VIX_API and related documents, DLLs, Lib, and so on.
First, include the header file, connect Lib
Vix.h, Vm_basic_types.h, VixAllProducts.lib, VixAllProductsd.lib
Second, follow the instructions in the documentation Vix_api
Vixhost_connect()、Vixhost_disconnect()、Vixhost_finditems()、VIXHOST_REGISTERVM()、VIXHOST_UNREGISTERVM()、vixjob_checkcompletion()、Vixjob_geterror()、vixjob_getnthproperties()、vixjob_getnumproperties()、vixjob_wait()、Vixsnapshot_getchild()、Vixsnapshot_getnumchildren()、vixsnapshot_getparent()、Vixvm_addsharedfolder()、Ixvm_copyfilefromguesttohost()、vixvm_copyfilefromhosttoguest()、vixvm_createdirectoryinguest()、Vixvm_createsnapshot()、vixvm_createtempfileinguest()、Vixvm_delete()、vixvm_deletedirectoryinguest()、vixvm_deletefileinguest (),vixvm_directoryexistsinguest (),vixvm_enablesharedfolders (),vixvm_fileexistsinguest (),vixvm_getcurrentsnapshot (),vixvm_getnamedsnapshot (),vixvm_getnumrootsnapshots (),vixvm_getnumsharedfolders (),vixvm_getrootsnapshot (),vixvm_getsharedfolderstate (),vixvm_installtools (),vixvm_killprocessinguest (),vixvm_listdirectoryinguest (),vixvm_listprocessesinguest (),vixvm_logininguest (),vixvm_logoutfromguest (),Vixvm_open (),vixvm_openurlinguest (),Vixvm_poweroff (),Vixvm_poweron (),Vixvm_removesharedfolder (),vixvm_removesnapshot (),vixvm_renamefileinguest (),Vixvm_reset (),vixvm_reverttosnapshot (),vixvm_runprograminguest (),vixvm_runscriptinguest (),vixvm_setsharedfolderstate (),vixvm_suspend (),Vixvm_upgradevirtualhardware (),vixvm_waitfortoolsinguest (),Vix_freebuffer (),Vix_geterrortext (),Vix_gethandletype (),vix_getproperties (),Vix_getpropertytype (),vix_pumpevents (),Vix_releasehandle (),
Third, use the correct DLL file
I have encountered this problem that bothered me for a day to debug. There is a description in the document, different versions of VMware corresponding to different DLL files, otherwise there will be an error in the vixhost_connect of the parameters to report errors!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Depending on the practice, the command-line mode is first transferred to the VIX directory, but only one command is valid, Vmrun start "(. VMX absolute path, do not appear in Chinese)", and if there are other possible commands welcome comment.
(turn) Vix_api operation VMware