Recently I saw the j-Interop, Amazingly it’s a awesome COM bridge. I tried this for our internal R&D. While doing, we have a requirement. “We have a tiny application as a msi package, we want to install this package across all the widows machines in the having a common administration windows domain account.”. We can do this from a windows machine, but in our deployment, we don’t want to use a windows machine, we would love to use the j-interop.
Can we transfer a file to a windows machine and invoke/run the same file? Using j-interop? Any suggestions?, welcome
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
seems like you're trying to do this the hard way…. You can install MSIs as group policy objects in an Active Directory domain.
See:
If you want to do this in the manner you describe above, then you should put the MSI in a share with file share access, then you could use a remote command execution to execute the MSI. To do the remote execution you need to create a new instance of a Win32\_Process. See for some C#/VB examples, but the mindeset is similar. Create the Win32_Process set the cmd line properties on it, then execute the "Create" method on the Win32\_Process.
Hi Scottley
Thanks for your quick reply. We did the similar approach with C++/xCmd.exe. it was fine. But, mine is a linux appliance, i can't run win_32 apps on linux and no common shares and no Windows Domain.
I just have linux and java/j-interop. please help me out.
Thanks in advance
PC Varma
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wrote a program to copy file from my linux box to a windows box with API. Its working fine for other than binary files.
But i need to copy the binary file. i have attached the code, please help me out.
Basically, i need to read the binsry data and write the binary data to the stream as byte array, but with j-interop… i could create JIByteArray or JIArray with java Byte Array data.
Recently I saw the j-Interop, Amazingly it’s a awesome COM bridge. I tried this for our internal R&D. While doing, we have a requirement. “We have a tiny application as a msi package, we want to install this package across all the widows machines in the having a common administration windows domain account.”. We can do this from a windows machine, but in our deployment, we don’t want to use a windows machine, we would love to use the j-interop.
Can we transfer a file to a windows machine and invoke/run the same file? Using j-interop? Any suggestions?, welcome
seems like you're trying to do this the hard way…. You can install MSIs as group policy objects in an Active Directory domain.
See:
If you want to do this in the manner you describe above, then you should put the MSI in a share with file share access, then you could use a remote command execution to execute the MSI. To do the remote execution you need to create a new instance of a Win32\_Process. See for some C#/VB examples, but the mindeset is similar. Create the Win32_Process set the cmd line properties on it, then execute the "Create" method on the Win32\_Process.
: http://support.microsoft.com/kb/816102
: http://www.dalun.com/blogs/05.09.2007.htm
Hi Scottley
Thanks for your quick reply. We did the similar approach with C++/xCmd.exe. it was fine. But, mine is a linux appliance, i can't run win_32 apps on linux and no common shares and no Windows Domain.
I just have linux and java/j-interop. please help me out.
Thanks in advance
PC Varma
Hi All
I wrote a program to copy file from my linux box to a windows box with API. Its working fine for other than binary files.
But i need to copy the binary file. i have attached the code, please help me out.
Basically, i need to read the binsry data and write the binary data to the stream as byte array, but with j-interop… i could create JIByteArray or JIArray with java Byte Array data.
import java.io.FileInputStream;
import java.io.IOException;
import java.util.logging.Level;
import org.jinterop.dcom.common.JIException;
import org.jinterop.dcom.common.JISystem;
import org.jinterop.dcom.core.JIComServer;
import org.jinterop.dcom.core.JIProgId;
import org.jinterop.dcom.core.JISession;
import org.jinterop.dcom.core.JIString;
import org.jinterop.dcom.core.JIVariant;
import org.jinterop.dcom.impls.JIObjectFactory;
import org.jinterop.dcom.impls.automation.IJIDispatch;
public class CopyFile {
private static JISession configAndConnectDCom(String domain, String user,
String pass) throws Exception {
JISystem.getLogger().setLevel(Level.OFF);
try {
JISystem.setInBuiltLogHandler(false);
} catch (IOException ignored) {
;
}
JISystem.setAutoRegisteration(true);
JISession dcomSession = JISession.createSession(domain, user, pass);
dcomSession.useSessionSecurity(true);
return dcomSession;
}
private static IJIDispatch getWmiLocator(String host, JISession dcomSession)
throws Exception {
JIComServer wbemLocatorComObj = new JIComServer(JIProgId
.valueOf("ADODB.Stream"), host, dcomSession);
// JIComServer wbemLocatorComObj = new JIComServer( JIProgId.valueOf(
// "Scripting.FileSystemObject" ), host, dcomSession );
return (IJIDispatch) JIObjectFactory.narrowObject(wbemLocatorComObj
.createInstance().queryInterface(IJIDispatch.IID));
}
private static IJIDispatch toIDispatch(JIVariant comObjectAsVariant)
throws JIException {
return (IJIDispatch) JIObjectFactory.narrowObject(comObjectAsVariant
.getObjectAsComObject());
}
public static void main(String args) {
String domain = "<domain>";
String host = "<ip>";
String user = "<user name>";
String pass = "<passwd>";
JISession dcomSession = null;
try {
dcomSession = configAndConnectDCom(domain, user, pass);
IJIDispatch wbemLocator = getWmiLocator(host, dcomSession);
FileInputStream fin = new FileInputStream(
"/tmp/file.exe");
String inputLine = "";
byte b = new byte;
int len = 0;
java.io.DataInputStream din = new java.io.DataInputStream(fin);
wbemLocator.callMethodA("open", new Object {});
while (din.available() > 0) {
len = din.read(b);
wbemLocator.callMethod("WriteText", new Object {
new JIString(new String(b, 0, len, "UTF-8"), 1), 1 });
}
wbemLocator.callMethodA("SaveToFile", new Object {
new JIString("C:/temp/file.exe"), 2 });
wbemLocator.callMethod("Close", new Object {});
fin.close();
System.out.println("done");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != dcomSession) {
try {
JISession.destroySession(dcomSession);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}