2013-02-07 43 views
0

我想修改Msvm_VirtualSystemManagementService資源並希望使用Msvm_VirtualSystemManagementService的DestroySystem方法..爲此,我希望獲取對CIM_ComputerSystem實例的引用,該實例將虛擬機實例被銷燬。但我不知道如何使用J-互操作得到..請幫助me..ThanksHyper-V刪除虛擬機J-Interop

回答

0

使用http://jwbem.sourceforge.net/你應該能夠得到一個Msvm_ComputerSystem參考

(從jwbem DOC樣品)

import com.hyper9.jwbem.SWbemObjectSet; 
import com.hyper9.jwbem.msvm.MsvmComputerSystem; 

... 

// Define the WQL query that returns all of a Hyper-V's virtual machines. 
String wql = "SELECT * FROM Msvm_ComputerSystem WHERE Caption='Virtual Machine'"; 

// Execute the query. 
SWbemObjectSet<MsvmComputerSystem> compSysSet = svc.execQuery(wql, MsvmComputerSystem.class); 

// Print the names of the virtual machines. 
for (MsvmComputerSystem cs : compSysSet) 
{ 
    System.out.println(cs.getElementName()); 
}