Jacob-检索系统还原信息(Java)
我的应用程序需要列出使用java的计算机上所有可用的还原点()。SystemRestore类位于默认命名空间中,不在CIMV2中。当我尝试以下代码时:Jacob-检索系统还原信息(Java),java,jacob,Java,Jacob,我的应用程序需要列出使用java的计算机上所有可用的还原点()。SystemRestore类位于默认命名空间中,不在CIMV2中。当我尝试以下代码时: public class TestWMI { public static void main(String args[]){ String host = "localhost"; String connectStr = String.format("winmgmts:\\\\%s\\root\\defaul
public class TestWMI {
public static void main(String args[]){
String host = "localhost";
String connectStr = String.format("winmgmts:\\\\%s\\root\\default", host);
String query = "SELECT * FROM SystemRestore";
ActiveXComponent axWMI = new ActiveXComponent(connectStr);
Variant vCollection = axWMI.invoke("ExecQuery", new Variant(query));
EnumVariant enumVariant = new EnumVariant(vCollection.toDispatch());
Dispatch item = null;
while (enumVariant.hasMoreElements()) {
item = enumVariant.nextElement().toDispatch();
String serviceName = Dispatch.call(item,"Description").toString();
System.out.println();
}
}
}
但最终会出现以下错误:
Exception in thread "main" com.jacob.com.ComFailException: IEnumVARIANT::Next
at com.jacob.com.EnumVariant.Next(Native Method)
at com.jacob.com.EnumVariant.hasMoreElements(EnumVariant.java:68)
at TestWMI.main(TestWMI.java:28)
Java Result: 1
请帮助。这里我们有一篇帖子说,不要以管理员身份运行 下面是一个示例,您通过查询外部数据WMI别名得到相同的错误,但在使用
select
时应该查询全名
SELECT Index,InterfaceIndex,SettingID,IpAddress,ServiceName,Description
FROM NICCONFIG
WHERE IPEnabled=true
应该是:
SELECT Index,InterfaceIndex,SettingID,IpAddress,ServiceName,Description
FROM Win32_NetworkAdapterConfiguration
WHERE IPEnabled=true
以下是外部别名(来自命令行)或全名(来自WMI API调用)的示例