Thank you for reply.
I have not tried with sc.exe. But I have used below code to start and
stop web service.
import java.io.*;
public class WindowsServicesManager {
static final String CMD_START = "cmd /c net start \"";
static final String CMD_STOP = "cmd /c net stop \"";
public static int startService(String serviceName) throws Exception {
return execCmd(CMD_START + serviceName + "\"");
}
public static int stopService(String serviceName) throws Exception {
return execCmd(CMD_STOP + serviceName + "\"");
}
static int execCmd(String cmdLine) throws Exception {
Process process = Runtime.getRuntime().exec(cmdLine);
StreamPumper outPumper = new StreamPumper(process.getInputStream(),
System.out);
StreamPumper errPumper = new StreamPumper(process.getErrorStream(),
System.err);
outPumper.start();
errPumper.start();
process.waitFor();
outPumper.join();
errPumper.join();
return process.exitValue();
}
static class StreamPumper extends Thread {
private InputStream is;
private PrintStream os;
public StreamPumper(InputStream is, PrintStream os) {
this.is = is;
this.os = os;
}
public void run() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = br.readLine()) != null)
os.println(line);
}
catch (Exception e) {
e.printStackTrace();
}
}
This is working fine only problem is that automation execution happens
in hide mode (Not actually open the browser). I am trying to find
another way as well to overcome this problem.
Thanks again for reply.
Amit
On Apr 2, 5:27 pm, Krishnan Mahadevan
<
krishnan.mahadevan1...@gmail.com> wrote:
> Darrell,
> My bad. Perhaps it would have been more clear had it been merely mentioned
> as "start and stop the Grid/hub" :)
> Not used to seeing references to the grid as "selenium rc server on remote
> machine using webdriver" :)
>
> Thanks & Regards
> Krishnan Mahadevan
>
> "All the desirable things in life are either illegal, expensive, fattening
> or in love with someone else!"
>
>
>
> On Mon, Apr 2, 2012 at 5:26 PM, darrell <
darrell.grain...@gmail.com> wrote:
> > Krishnan,
>
> > You are missing something obvious. In the very first sentence of Amit's
> > posting it states , "My aim is to start and stop selenium RC server on *remote
> > machine* using webdriver." Therefore the question is about maintaining a
> >>> To view this discussion on the web visithttps://
groups.google.com/d/**
> >>> msg/webdriver/-/6yZZEtht3VIJ<
https://groups.google.com/d/msg/webdriver/-/6yZZEtht3VIJ>
> >>> .
> >>> To unsubscribe from this group, send email to webdriver+unsubscribe@**
> >>>
googlegroups.com <
webdriver%2Bunsu...@googlegroups.com>.
> >>> For more options, visit this group athttp://
groups.google.com/**
> >>> group/webdriver?hl=en <
http://groups.google.com/group/webdriver?hl=en>.