kramero
asked on
Stopping other services after receiving STOP_SERVICE signal
I am writing a service.
When my service receives SERVICE_STOP or SERVICE_SHUTDOWN
signal, it is notifying the SCM that it is stopping,
and starts the stopping procedure.
In the stopping procedure,
it should stop another service. For example (c code):
system("net stop wins");
but when I do that, it does not work.
Any other command line would work, but stopping a service
just gets stuck.
Where have I gone wrong ?
Is there a special way to stop a service from inside service stopping procedure ?
Sorry I can't give more points.
That's all I got left.
When my service receives SERVICE_STOP or SERVICE_SHUTDOWN
signal, it is notifying the SCM that it is stopping,
and starts the stopping procedure.
In the stopping procedure,
it should stop another service. For example (c code):
system("net stop wins");
but when I do that, it does not work.
Any other command line would work, but stopping a service
just gets stuck.
Where have I gone wrong ?
Is there a special way to stop a service from inside service stopping procedure ?
Sorry I can't give more points.
That's all I got left.
ASKER
Hi alexo.
I am familiar with this API call.
What I am looking for is an explanation for the fact that
a script running NET STOP <service name> gets stuck.
I am familiar with this API call.
What I am looking for is an explanation for the fact that
a script running NET STOP <service name> gets stuck.
The problem why your script gets stuck is that a service doesn't have the rights to access (and therefore execute) a script - this is a common problem with services that aren't assigned to run under a certain account. Two ways to overcome this: Assign your service to account manually (using the control panel) or use 'LogonUser()' and 'ImpersonateLoggedOnUser() ' to accomplish this...
ASKER
Hy JKR!
My service secceeds to run the script.
Everything in the script is OK until the NET STOP <...>.
If I take off the NET STOP command everything runs fine.
So I guess access is not the problem.
Maybe it has something to do with the SCM.
My service secceeds to run the script.
Everything in the script is OK until the NET STOP <...>.
If I take off the NET STOP command everything runs fine.
So I guess access is not the problem.
Maybe it has something to do with the SCM.
ASKER
Adjusted points to 85
Well, i still think that it is a privilege problem (e.g. insufficiant rights for a service to execute 'net.exe'). Try to assign the service to a user account, and then let's see ;-)
>> Try to assign the service to a user account
Also make sure that the account has the "run as service" privilege.
Also make sure that the account has the "run as service" privilege.
>>Also make sure that the account has the "run as service"
>>privilege.
alexo, you're right of course ;-)
>>privilege.
alexo, you're right of course ;-)
ASKER
Well,
Assigning the service to a user account with "run as service"
didn't work.
Using ServiceControl (Openning SCM etc...)
didn't work too.
It looks like from inside a stopping procedure of a service,
you can not ask to stop other services.
I don't know why!
and I can't find any documentation.
By the way -
Dependent Services wont help me in this case,
Don't ask me why. It's too long to explain...
I just need to find out how to stop a service from a stopping service...
Assigning the service to a user account with "run as service"
didn't work.
Using ServiceControl (Openning SCM etc...)
didn't work too.
It looks like from inside a stopping procedure of a service,
you can not ask to stop other services.
I don't know why!
and I can't find any documentation.
By the way -
Dependent Services wont help me in this case,
Don't ask me why. It's too long to explain...
I just need to find out how to stop a service from a stopping service...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By the way, this is not a "C" question. You should have asked it in the "Windows" programming area.