Package org.jinterop.dcom.impls.automation

Examples of org.jinterop.dcom.impls.automation.IJIDispatch


            for (int i = 0; i < count; i++) {
                Object[] values = enumVARIANT.next(1);
                JIArray array = (JIArray) values[0];
                Object[] arrayObj = (Object[]) array.getArrayInstance();
                for (int j = 0; j < arrayObj.length; j++) {
                    IJIDispatch wbemObject_dispatch = (IJIDispatch) JIObjectFactory.narrowObject(((JIVariant) arrayObj[j]).getObjectAsComObject());
                    JIVariant variant2 = (JIVariant) (wbemObject_dispatch.callMethodA("GetObjectText_", new Object[]{Integer.valueOf(1)}))[0];

                    // normally arrayObj.length is 1
                    if (j == 0)
                        processInfo[i] = variant2.getObjectAsString().getString();
                }
View Full Code Here


            // Execute command
            JIComServer comStub = new JIComServer(JIProgId.valueOf("WScript.Shell"),
                    bonafides.getHost(), session);
            IJIComObject unknown = comStub.createInstance();
            IJIComObject comobject = unknown.queryInterface(IJIDispatch.IID);
            IJIDispatch shell = (IJIDispatch) JIObjectFactory.narrowObject(comobject);

            Object[] scriptArgs = new Object[]{
                new JIString("%comspec% /c " + cmd)
            };

            // ref: http://stackoverflow.com/questions/6781340/how-to-call-a-remote-bat-file-using-jinterop

            JIVariant results[] = shell.callMethodA("Exec", scriptArgs);
            final IJIDispatch wbemObjectSet_dispatch =
                    (IJIDispatch) JIObjectFactory.narrowObject((results[0]).getObjectAsComObject());

            JIVariant stdOutJIVariant = wbemObjectSet_dispatch.get("StdOut");

            IJIDispatch stdOut =
                    (IJIDispatch) JIObjectFactory.narrowObject(stdOutJIVariant.getObjectAsComObject());

            // Read all from stdOut
            StringBuilder sb = new StringBuilder();

            while (!((JIVariant) stdOut.get("AtEndOfStream")).getObjectAsBoolean()) {
                sb.append(stdOut.callMethodA("ReadAll").getObjectAsString().getString());
            }

            return sb.toString();
        }
        catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.jinterop.dcom.impls.automation.IJIDispatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.