public class WindowsRemoteProcessLauncher extends Object
This mechanism depends on the RPC and DCOM. We first remotely create a service on the target machine and starts it. This service will accept a named pipe connection, which is used to launch the process and shuttle back and forth stdin and stdout+stderr.
| Constructor and Description |
|---|
WindowsRemoteProcessLauncher(String hostName,
org.jinterop.dcom.common.IJIAuthInfo credential) |
| Modifier and Type | Method and Description |
|---|---|
String |
getHostName()
Host that this launcher represents.
|
Process |
launch(String command,
String workingDirectory)
Launches a process remotely.
|
void |
setConnectionTimeout(int milliseconds)
Sets the connection timeout in milli-seconds.
|
public WindowsRemoteProcessLauncher(String hostName, org.jinterop.dcom.common.IJIAuthInfo credential)
hostName - Remote Windows host name or IP address to connect to.credential - User account on the target Windows machine. This needs to have sufficient privilege
to access administrative shares and install a service. Normally you have to be an
administrator to be able to do this.public void setConnectionTimeout(int milliseconds)
public String getHostName()
public Process launch(String command, String workingDirectory) throws IOException, org.jinterop.dcom.common.JIException, InterruptedException
The resulting Process behaves slightly differently from a normal local Process
in the following ways:
Process.getOutputStream().
This behavior is like ProcessBuilder.redirectErrorStream(true).
Process.waitFor(), Process.exitValue() will
never return an exit code.
command - Command to execute. Note that on Windows the command line argument is a single string, unlike Unix.
The implementation executes this through cmd.exe, so one can execute cmd.exe internal commands,
such as echo, copy, etc.workingDirectory - The working directory to launch the process with.IOExceptionorg.jinterop.dcom.common.JIExceptionInterruptedExceptionCopyright © 2004-2013. All Rights Reserved.