checking the state of a window service through Java -
I am looking for a way to see the service conditions of windows through Java. With some basic searches through Google and it seems that there is no API to find Windows services in Java.
Windows is running at the command prompt: sc \ some_host_name query "serviceName"
I want to be able to run information in Java program and now I want to be able to parse the output I am
Does anyone know a way to run Windows commands via Java?
Looks like you need Java 5+.
A quick example (based on the above documentation)
To start a process:
process p = new process builder ("Sc", "\\ some_host_name", "query", "serviceName"). Start ();
The class provides ways to get the stream (and error) from the process - it's standard stream handling from there.
Pre-Java 5 The way to do this is runtime .exec (). I did not really use ProcessorBuilder on Windows, if you have problems, leave comments?
Comments
Post a Comment