jinterop を使用してリモート PC で wmi クエリを実行しようとしていますが、dcom セッションを開始することさえできません。powershell\wmic\vbscript で問題なくアクセスできるため、wmi が機能していることはわかっています。また、Windows クライアントではファイル共有が無効になっています。
ここに私がしようとしているものがあります:
import static org.jinterop.dcom.impls.JIObjectFactory.narrowObject;
import static org.jinterop.dcom.impls.automation.IJIDispatch.IID;
import java.net.UnknownHostException;
import org.jinterop.dcom.common.JIException;
import org.jinterop.dcom.core.JIComServer;
import org.jinterop.dcom.core.JISession;
import org.jinterop.dcom.impls.automation.IJIDispatch;
import static org.jinterop.dcom.core.JIProgId.valueOf;
import org.jinterop.dcom.core.JIVariant;
import org.jinterop.dcom.core.JIString;
public class SimpleServiceManager {
public static void main(String[] args) {
String domain = "mydom";
String hostname = "remotepc";
String username = "myusername";
String password = "mypass";
JISession dcomSession = JISession.createSession(domain, username, password);
JIComServer comServer;
try {
comServer = new JIComServer(valueOf("WbemScripting.SWbemLocator"), hostname, dcomSession);
IJIDispatch wbemLocator = (IJIDispatch) narrowObject(comServer.createInstance().queryInterface(IID));
Object[] params = new Object[] {
new JIString(hostname),
new JIString("ROOT\\CIMV2"),
JIVariant.OPTIONAL_PARAM(),
JIVariant.OPTIONAL_PARAM(),
JIVariant.OPTIONAL_PARAM(),
JIVariant.OPTIONAL_PARAM(),
new Integer(0),
JIVariant.OPTIONAL_PARAM()
};
JIVariant results[] = wbemLocator.callMethodA("ConnectServer", params);
IJIDispatch wbemServices = (IJIDispatch) narrowObject(results[0].getObjectAsComObject());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
私にこれを与えます:
Apr 10, 2013 1:14:38 PM org.jinterop.dcom.common.JISystem logSystemPropertiesAndVersion
INFO: j-Interop Version = j-Interop 2.08
Apr 10, 2013 1:14:38 PM org.jinterop.dcom.common.JISystem logSystemPropertiesAndVersion
INFO: java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = C:\Program Files\Java\jre7\bin
java.vm.version = 23.7-b01
java.vm.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
path.separator = ;
java.vm.name = Java HotSpot(TM) Client VM
file.encoding.pkg = sun.io
user.country = US
user.script =
sun.java.launcher = SUN_STANDARD
sun.os.patch.level = Service Pack 1
java.vm.specification.name = Java Virtual Machine Specification
user.dir = C:\Users\myusername\Google Drive\code\Workspaces\Eclipse IDE for Java Developers 422\Jinterop
java.runtime.version = 1.7.0_17-b02
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs = C:\Program Files\Java\jre7\lib\endorsed
os.arch = x86
java.io.tmpdir = C:\Users\myusername\AppData\Local\Temp\
line.separator =
java.vm.specification.vendor = Oracle Corporation
user.variant =
os.name = Windows 7
sun.jnu.encoding = Cp1252
java.library.path = C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;...
java.specification.name = Java Platform API Specification
java.class.version = 51.0
sun.management.compiler = HotSpot Client Compiler
os.version = 6.1
user.home = C:\Users\myusername
user.timezone = America/New_York
java.awt.printerjob = sun.awt.windows.WPrinterJob
file.encoding = Cp1252
java.specification.version = 1.7
java.class.path = C:\Users\myusername\Google Drive\code\Workspaces\Eclipse IDE for Java Developers 422\Jinterop\bin;C:\Users\myusername\Google Drive\code\Workspaces\Eclipse IDE for Java Developers 422\Jinterop\libs\j-interop.jar;C:\Users\myusername\Google Drive\code\Workspaces\Eclipse IDE for Java Developers 422\Jinterop\libs\j-interopdeps.jar;C:\Users\myusername\Google Drive\code\Workspaces\Eclipse IDE for Java Developers 422\Jinterop\libs\jcifs-1.2.19.jar
user.name = myusername
java.vm.specification.version = 1.7
sun.java.command = SimpleServiceManager
java.home = C:\Program Files\Java\jre7
sun.arch.data.model = 32
user.language = en
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.windows.WToolkit
java.vm.info = mixed mode, sharing
java.version = 1.7.0_17
java.ext.dirs = C:\Program Files\Java\jre7\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path = C:\Program Files\Java\jre7\lib\resources.jar;C:\Program Files\Java\jre7\lib\rt.jar;C:\Program Files\Java\jre7\lib\sunrsasign.jar;C:\Program Files\Java\jre7\lib\jsse.jar;C:\Program Files\Java\jre7\lib\jce.jar;C:\Program Files\Java\jre7\lib\charsets.jar;C:\Program Files\Java\jre7\lib\jfr.jar;C:\Program Files\Java\jre7\classes
java.vendor = Oracle Corporation
file.separator = \
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
sun.desktop = windows
sun.cpu.isalist = pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
Apr 10, 2013 1:14:38 PM org.jinterop.dcom.core.JIComOxidRuntime$ClientPingTimerTask run
INFO: Running ClientPingTimerTask !
Apr 10, 2013 1:14:38 PM org.jinterop.dcom.core.JISession createSession
INFO: Created Session: -1745354837
Apr 10, 2013 1:14:38 PM org.jinterop.dcom.core.JIComOxidRuntime$ServerPingTimerTask run
INFO: Running ServerPingTimerTask !
Apr 10, 2013 1:14:38 PM org.jinterop.dcom.core.JISession$Release_References_TimerTask run
INFO: Release_References_TimerTask:[RUN] Session: -1745354837 , listOfDeferencedIpids.size(): 0
Apr 10, 2013 1:14:38 PM org.jinterop.dcom.common.JISystem saveDBPathAndLoadFile
INFO: progIdVsClsidDB: {}
org.jinterop.dcom.common.JIException: Message not found for errorCode: 0xC0000034
at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKLM(JIWinRegStub.java:115)
at org.jinterop.dcom.core.JIProgId.getIdFromWinReg(JIProgId.java:130)
at org.jinterop.dcom.core.JIProgId.getCorrespondingCLSID(JIProgId.java:162)
at org.jinterop.dcom.core.JIComServer.<init>(JIComServer.java:413)
at SimpleServiceManager.main(SimpleServiceManager.java:25)
Caused by: jcifs.smb.SmbException: The system cannot find the file specified.
at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:522)
at jcifs.smb.SmbTransport.send(SmbTransport.java:622)
at jcifs.smb.SmbSession.send(SmbSession.java:239)
at jcifs.smb.SmbTree.send(SmbTree.java:109)
at jcifs.smb.SmbFile.send(SmbFile.java:718)
at jcifs.smb.SmbFile.open0(SmbFile.java:923)
at jcifs.smb.SmbFile.open(SmbFile.java:940)
at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:142)
at jcifs.smb.TransactNamedPipeOutputStream.<init>(TransactNamedPipeOutputStream.java:32)
at jcifs.smb.SmbNamedPipe.getNamedPipeOutputStream(SmbNamedPipe.java:187)
at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:92)
at rpc.Stub.attach(Stub.java:106)
at rpc.Stub.call(Stub.java:110)
at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKLM(JIWinRegStub.java:113)
... 4 more
jcifs.smb.SmbException がスローされるのはなぜですか? WMI は smb を使用しないのに、なぜこのエラーが表示されるのですか? jinterop では、クライアントで Windows ファイル共有を有効にする必要がありますか?