2015年11月1日 星期日

如何 執行 一個 執行檔 在 虛擬機裡 Programmatically executing a program in a VMware machine

如何 執行 一個 執行檔 在 虛擬機裡 Programmatically executing a program in a VMware machine  
  

As reported in the documentation of the VMware API, the function you need is VixVM_RunProgramInGuest(), which requires you to authenticate on the guest OS (the OS running on the virtual machine) with VixVM_LoginInGuest().

// Authenticate for guest operations.   
jobHandle = VixVM_LoginInGuest(vmHandle,
  "vixuser", // userName
  "secret",  // password 
  0,         // options
  NULL,      // callbackProc
  NULL       // clientData
); 

/*
 VIX_E_PROGRAM_NOT_STARTED error code.
*/

err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);    

if (VIX_OK != err) {
  // Handle the error.
  goto abort;
}

Vix_ReleaseHandle(jobHandle);

// Run the target program.  
jobHandle = VixVM_RunProgramInGuest(vmHandle,
  "c:\\myProgram.exe",
  "/flag arg1 arg2",
  0,                  // options
  VIX_INVALID_HANDLE, // propertyListHandle
  NULL,               // callbackProc
  NULL                // clientData
); 
/*
 VIX_E_PROGRAM_NOT_STARTED error code.

VixHandle
VixVM_RunProgramInGuest(VixHandle vmHandle,
const char *guestProgramName,
const char *commandLineArgs,
VixRunProgramOptions options,
VixHandle propertyListHandle,
VixEventProc *callbackProc,
void *clientData);

*/
err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);

if (VIX_OK != err) {
  // Handle the error.
  goto abort;
}

Vix_ReleaseHandle(jobHandle);
The part to connect to the virtual machine server is the following one.

jobHandle = VixHost_Connect(VIX_API_VERSION,
  VIX_SERVICEPROVIDER_VMWARE_SERVER,
  NULL,               // hostName
  0,                  // hostPort
  NULL,               // userName
  NULL,               // password
  0,                  // options
  VIX_INVALID_HANDLE, // propertyListHandle
  NULL,               // callbackProc
  NULL                // clientData
); 

err = VixJob_Wait(jobHandle, VIX_PROPERTY_JOB_RESULT_HANDLE, &hostHandle, VIX_PROPERTY_NONE);

if (VIX_OK != err) {
  // Handle the error.
  goto abort;
}

Vix_ReleaseHandle(jobHandle);


The documentation has an example on how to call a program in the guest OS; it's a complete example that shows how to connect to the virtual machine server, open a file defining a virtual machine, and power it on. The essential code is the following one; you should read the complete example, though.

優秀 的 性能 CrossOver 在 mac linux 上跑 windows 的 api 虛擬機 winehq

CrossOver 在 mac linux 上跑 windows 的 api 虛擬機

比vmware 更快 ,@@ !!!  Boot Camp是多重開機

mac 下的 虛擬機


//////////////////////////////


CrossOver 14 Mac 版讓您可以在 Mac 系統上運行 Microsoft Windows 應用,不必購買 Windows 授權,不必重啓系統,不必使用虛擬機。通過 CrossOver Mac,您可以從 dock 直接啓動 Windows 應用,與您的 Mac OS 系統功能無縫集成,實現跨平台的複製粘貼和文件互通。

CrossOver Mac 支持 Windows 辦公軟件,工具程序和各種遊戲。CrossOver Mac 避免了虛擬機的運行開銷,程序和遊戲的性能可以達到甚至超過它們在 Windows 下的表現。

運行 Windows 應用
再也不必重啓
像運行原生應用一樣,直接從您的 Mac Linux 系統上運行您的 Windows 應用。

一鍵安裝
CrossOver 一鍵安裝技術讓 Windows 程序使用更簡單。

全速運行
沒有性能損耗,在您最喜歡的系統上使用您熟悉的應用。
無縫集成
與桌面環境融為一體

跨平台的複製粘帖和文件互通。

CodeWeavers 支援於 開放原始碼專案 Wine Project
  
費用

CrossOver Mac
12個月 升級與支持
購買之前 下載免費試用版
 更多選項...
$59.95 USD 
6個月升級與支持
 $49.95 USD 

1個月升級與支持


//////////////////////////////

其他相似的

Similar SoftwareClose Comparison

//////////////////////////////


  • WineBottler 
Free
Bottle Windows apps as Mac application bundles (beta).


  • VirtualBox 
Free
x86 virtualization software.
VirtualBox (Windows/Mac OS X/Linux) Free ( Oracle VM VirtualBox )功能簡單的 虛擬機 (需要安裝windows)


  • Wineskin Wine… 
Free 
Make Wine wrappers to run Windows software on Mac OS X.


  • CrossOver 
$59.95 

Run Windows apps on your Mac.


  • PlayOnMac 
https://www.playonmac.com/en/
Free
Run Windows apps on your Mac. 


PlayOnMac is free software that allows you to easily install and use numerous games and software designed to work on Microsoft® Windows®.
他說可以提供你應用程式在Mac osx 上執行( 免虛擬環境 ),其實是利用類似 wineHQ 的東西, 加上“sandbox”技術,讓你經過他的環境來管理程式


  • VMware

http://www.vmware.com/tw(
Windows/Mac OS X/Linux) Free to $250 開放原始碼且 商業化 (需要安裝windows)


  • Parallels Desktop 9

http://www.parallels.com/tw/products/desktop/
(Mac OS X) $80 商業化 虛擬機 (需要安裝windows)
https://en.wikipedia.org/wiki/Parallels_Desktop_for_Mac


  • QEMU (Linux)

http://wiki.qemu.org/Main_Page
Free 主要是讓你跑linux 程式在mac上

https://github.com/psema4/pine/wiki/Installing-QEMU-on-OS-X
To emulate the Raspberry Pi on OS X, you need a version of QEMU that supports the ARM 1176 instruction set (QEMU version 1.1.0 exactly).


  • Wine

https://www.winehq.org
老牌api 虛擬 改名 "WIN HQ "http://wiki.winehq.org/MacOSX open source 可以成功執行大部分win程式 (原本目標是win on linux )


  • Wine bottler

http://winebottler.kronenberg.org
api 虛擬  "WIN HQ "的mac版


  • WinOnX
http://www.winonx.com


  • Boot Camp

https://en.wikipedia.org/wiki/Boot_Camp_(software)
 (Mac OS X)  Free apple 開發給你安裝windows 在mac上的多重開機管理器


//////////////////////////////


  • 名為模擬器的blog,有趣, 不過講的是 遊戲機 模擬器
Emulation is a way of life. From collectors to hard core gamers alike. I have been following gaming and emulation for a little over ten years and it just keeps getting better. I recall the first first Nintendo 64 emulator like it was my first bike ride. Sure I had the game in the next room. I had even beaten it but it was the thought, the idea that my console could soon play on my computer. As gaming evolves, systems die or get replaced by the next best thing. Gaming doesn’t die, at least not while emulation and computers exist.
dos 在mac 跑 game http://boxerapp.com


  • 這認真的是 DOS 在 Mac (win 98 好像也可以) 
//////////////////////////////
https://en.wikipedia.org/wiki/Wine_(software)
Other versions of Wine
由於是“ 開放原始碼 軟體 , 所以 他的 分支 很多”
//////////////////////////////
  • CrossOver
  • Cedega / WineX
  • Cider
  • WINE@Etersoft
  • Darwin
  • Wine for Android
  • Pipelight/wine-compholio
Other projects using Wine source code
  • Wine bottler
  • Wineskin


Cycada (formerly known as Cider) is a compatibility layer that aims to allow applications designed for iOS to run 
unmodified on the Android operating system. 一個在 IOS iPhone iPad 上跑Android APP的 專案


Darling is a free and open source software application that aims to allow applications designed for OS X to run on the Linux operating system. Darling is a compatibility layer, like Wine. It duplicates functions of OS X by providing alternative implementations of the libraries and frameworks that OS X programs call.[2] This method of duplication differs from other methods that might also be considered emulation, where OS X programs run in a virtual machine.
讓你在 linux上執行 mac osx軟體