我正在尝试使用 j-interop 实现以下 wmic 命令。
wmic /NODE:192.168.0.195 /USER:Test /PASSWORD:password123 process call create "calc.exe"
我的代码在我的方法中是这样写的。我还有另外两种方法可以创建会话并连接到 WMI 服务,以便处理该部分。
public void wmiExecute() throws JIException {
// Obtain Win32_Process and narrow it as IJIDispatch
Object[] params = new Object[] {
new JIString("Win32_Process"),
new Integer(0),
JIVariant.OPTIONAL_PARAM()
};
JIVariant[] servicesSet = this._wbemServices.callMethodA("InstancesOf", params);
IJIDispatch wbemObjectSet = (IJIDispatch) JIObjectFactory.narrowObject(servicesSet[0].getObjectAsComObject());
params = new Object[] {
"calc.exe",
JIVariant.OPTIONAL_PARAM(),
JIVariant.OPTIONAL_PARAM(),
new Integer(0),
};
wbemObjectSet.callMethodA("Create", params);
}
我一直得到一个例外
Caught Throwable: org.jinterop.dcom.common.JIException: Unknown name. [0x80020006]
org.jinterop.dcom.common.JIException: Unknown name. [0x80020006]
知道有什么问题吗?提前致谢!