how to start system services...????
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   New_User
Posted On:   Tuesday, November 5, 2002 02:09 AM


			



hi gurus,

iam trying to start system services using java program
but i didnt succeed. Is there any gurus for me to help
here to provide a simple code with a bit explaination.
My aim is to read the status of services (start or stop)
if stopped, then the program should identify also able to start the process at the next moment.
thanx for the help.




Re: how to start system services...????

Posted By:   Gautam_Marwaha  
Posted On:   Tuesday, November 5, 2002 04:21 AM

Assuming you are talking about Windows services:


A very basic solution would be to use Runtime.exec to execute a DOS command, read the output to determine success (0) or failure (non zero) of the command.

Trying to start a service already running shd write an error to stdout or stdin. Similarly trying to stop a service already stopped will give an error. On the other hand, on successful start/stop you should be able to get an output code of zero.

Use getOutputStram(), getErrorStream() methods of Process class to fetch return err descriptions, use exitValue() for return code of the process.

General format for a DOS cmd using exec() is:

"cmd.exe /C net start MyService" or similar.

If this is too basic for you, consider writing native C code for this using win32 APIs and calling it via JNI.
About | Sitemap | Contact