system service can't restart itself

  • Thread starter Thread starter Simon Morris
  • Start date Start date
S

Simon Morris

I'd like a system service to be able to restart itself. I have a batch
file that stops and starts the service if I run it from a command line.
If that file is run from the service itself, then it stops the service,
but reports "OpenService FAILED 5: Access is denied" when it tries to
start the service.

The command line that works is run by the same user as the service logs
in as, so I think the permissions must be OK - and would it take more
permissions to start a service than to stop it?

Any ideas?

Thanks
 
More details about this are required.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
<snip>
| The command line that works is run by the same user as the service logs
| in as,
<snip>
 
Dave Patrick wrote on 19/05/2006 04:23
More details about this are required.

The batch file is just

sc stop ServiceName
sc start ServiceName

The system runs in the UserName account. If I run that batch file from
cmd running in the UserName account, it stops and starts the system
service OK. If the system service itself runs the batch file (it's a
Java app, so it uses Runtime.getRuntime.exec()), dumping the output to a
log file, then I can see that the stop command works, but the start
command gives the "Access denied" error.

S.
 
Not sure what you've got going but it's sounding more like a suicide
service.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| The batch file is just
|
| sc stop ServiceName
| sc start ServiceName
|
| The system runs in the UserName account. If I run that batch file from
| cmd running in the UserName account, it stops and starts the system
| service OK. If the system service itself runs the batch file (it's a
| Java app, so it uses Runtime.getRuntime.exec()), dumping the output to a
| log file, then I can see that the stop command works, but the start
| command gives the "Access denied" error.
|
| S.
 
Try adding some time delay.

sc stop ServiceName
ping -n 10 127.0.0.1
sc start ServiceName

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
 
Back
Top