My dll service disappears after restarting the system
up vote
0
down vote
favorite
I wrote a dll service in c++ with API functions and working properly. I implemented a ServiceMain() function as dllexport in which call RegisterServiceCtrlHandlerW() function to handle the incoming signals (e.g. stop, pause, ...) of my service.
Every thing working good and I defined all the necessary functions to run the service :
ServiceMain()is defined andRegisterServiceCtrlHandlerW()calls within to register control handler.- Set service status to
SERVICE_START_PENDINGthen toSERVICE_RUNNINGto run the service. - I implemented a
threadto do stuffs as service jobs and working properly. - And I can start and stop my service.
My service is a dll not exe so I'm using svchost.exe to host it and I did below steps to register in windows registry:
1. I create a new value in registry as a group to introduce my service to svchost.exe as following :

2. I create Parameters subkey And fill a value with my dll (service file) as following :

3. Also I defined a value (ServiceMain) due to introduce my ServiceMain function to svchost.exe as start point.
So far, my service working even in logged off user BUT when I restart my computer, after logon to windows my service disappeared from Windows Service Manager. Actually it is removed from SCM database.
By the way I installed my service with 3 methods. And I'm using svchost.exe as binarypath to install the service (because svchost.exe behave as host for my dll service). For example with sc.exe program I set binarypath to svchost.exe to run my service indirectly with -k groupname as parameters.
My problem is : When I restart my system then my service disappeared (is deleted) after logging in. Please help me to solve this problem.
c++ winapi windows-services
|
show 1 more comment
up vote
0
down vote
favorite
I wrote a dll service in c++ with API functions and working properly. I implemented a ServiceMain() function as dllexport in which call RegisterServiceCtrlHandlerW() function to handle the incoming signals (e.g. stop, pause, ...) of my service.
Every thing working good and I defined all the necessary functions to run the service :
ServiceMain()is defined andRegisterServiceCtrlHandlerW()calls within to register control handler.- Set service status to
SERVICE_START_PENDINGthen toSERVICE_RUNNINGto run the service. - I implemented a
threadto do stuffs as service jobs and working properly. - And I can start and stop my service.
My service is a dll not exe so I'm using svchost.exe to host it and I did below steps to register in windows registry:
1. I create a new value in registry as a group to introduce my service to svchost.exe as following :

2. I create Parameters subkey And fill a value with my dll (service file) as following :

3. Also I defined a value (ServiceMain) due to introduce my ServiceMain function to svchost.exe as start point.
So far, my service working even in logged off user BUT when I restart my computer, after logon to windows my service disappeared from Windows Service Manager. Actually it is removed from SCM database.
By the way I installed my service with 3 methods. And I'm using svchost.exe as binarypath to install the service (because svchost.exe behave as host for my dll service). For example with sc.exe program I set binarypath to svchost.exe to run my service indirectly with -k groupname as parameters.
My problem is : When I restart my system then my service disappeared (is deleted) after logging in. Please help me to solve this problem.
c++ winapi windows-services
1
Why don't you register the service using the API? Why hack at the registry?
– David Heffernan
Nov 19 at 13:37
@DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service tosvchost.exe
– Mohammadreza Panahi
Nov 19 at 13:44
Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
– David Heffernan
Nov 19 at 13:56
@DavidHeffernan according this stackoverflow.com/questions/30554180/…
– Mohammadreza Panahi
Nov 19 at 13:58
Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
– David Heffernan
Nov 19 at 14:24
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I wrote a dll service in c++ with API functions and working properly. I implemented a ServiceMain() function as dllexport in which call RegisterServiceCtrlHandlerW() function to handle the incoming signals (e.g. stop, pause, ...) of my service.
Every thing working good and I defined all the necessary functions to run the service :
ServiceMain()is defined andRegisterServiceCtrlHandlerW()calls within to register control handler.- Set service status to
SERVICE_START_PENDINGthen toSERVICE_RUNNINGto run the service. - I implemented a
threadto do stuffs as service jobs and working properly. - And I can start and stop my service.
My service is a dll not exe so I'm using svchost.exe to host it and I did below steps to register in windows registry:
1. I create a new value in registry as a group to introduce my service to svchost.exe as following :

2. I create Parameters subkey And fill a value with my dll (service file) as following :

3. Also I defined a value (ServiceMain) due to introduce my ServiceMain function to svchost.exe as start point.
So far, my service working even in logged off user BUT when I restart my computer, after logon to windows my service disappeared from Windows Service Manager. Actually it is removed from SCM database.
By the way I installed my service with 3 methods. And I'm using svchost.exe as binarypath to install the service (because svchost.exe behave as host for my dll service). For example with sc.exe program I set binarypath to svchost.exe to run my service indirectly with -k groupname as parameters.
My problem is : When I restart my system then my service disappeared (is deleted) after logging in. Please help me to solve this problem.
c++ winapi windows-services
I wrote a dll service in c++ with API functions and working properly. I implemented a ServiceMain() function as dllexport in which call RegisterServiceCtrlHandlerW() function to handle the incoming signals (e.g. stop, pause, ...) of my service.
Every thing working good and I defined all the necessary functions to run the service :
ServiceMain()is defined andRegisterServiceCtrlHandlerW()calls within to register control handler.- Set service status to
SERVICE_START_PENDINGthen toSERVICE_RUNNINGto run the service. - I implemented a
threadto do stuffs as service jobs and working properly. - And I can start and stop my service.
My service is a dll not exe so I'm using svchost.exe to host it and I did below steps to register in windows registry:
1. I create a new value in registry as a group to introduce my service to svchost.exe as following :

2. I create Parameters subkey And fill a value with my dll (service file) as following :

3. Also I defined a value (ServiceMain) due to introduce my ServiceMain function to svchost.exe as start point.
So far, my service working even in logged off user BUT when I restart my computer, after logon to windows my service disappeared from Windows Service Manager. Actually it is removed from SCM database.
By the way I installed my service with 3 methods. And I'm using svchost.exe as binarypath to install the service (because svchost.exe behave as host for my dll service). For example with sc.exe program I set binarypath to svchost.exe to run my service indirectly with -k groupname as parameters.
My problem is : When I restart my system then my service disappeared (is deleted) after logging in. Please help me to solve this problem.
c++ winapi windows-services
c++ winapi windows-services
edited Nov 23 at 20:45
Werner Henze
10.1k72550
10.1k72550
asked Nov 19 at 12:28
Mohammadreza Panahi
2,52021432
2,52021432
1
Why don't you register the service using the API? Why hack at the registry?
– David Heffernan
Nov 19 at 13:37
@DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service tosvchost.exe
– Mohammadreza Panahi
Nov 19 at 13:44
Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
– David Heffernan
Nov 19 at 13:56
@DavidHeffernan according this stackoverflow.com/questions/30554180/…
– Mohammadreza Panahi
Nov 19 at 13:58
Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
– David Heffernan
Nov 19 at 14:24
|
show 1 more comment
1
Why don't you register the service using the API? Why hack at the registry?
– David Heffernan
Nov 19 at 13:37
@DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service tosvchost.exe
– Mohammadreza Panahi
Nov 19 at 13:44
Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
– David Heffernan
Nov 19 at 13:56
@DavidHeffernan according this stackoverflow.com/questions/30554180/…
– Mohammadreza Panahi
Nov 19 at 13:58
Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
– David Heffernan
Nov 19 at 14:24
1
1
Why don't you register the service using the API? Why hack at the registry?
– David Heffernan
Nov 19 at 13:37
Why don't you register the service using the API? Why hack at the registry?
– David Heffernan
Nov 19 at 13:37
@DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service to
svchost.exe– Mohammadreza Panahi
Nov 19 at 13:44
@DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service to
svchost.exe– Mohammadreza Panahi
Nov 19 at 13:44
Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
– David Heffernan
Nov 19 at 13:56
Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
– David Heffernan
Nov 19 at 13:56
@DavidHeffernan according this stackoverflow.com/questions/30554180/…
– Mohammadreza Panahi
Nov 19 at 13:58
@DavidHeffernan according this stackoverflow.com/questions/30554180/…
– Mohammadreza Panahi
Nov 19 at 13:58
Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
– David Heffernan
Nov 19 at 14:24
Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
– David Heffernan
Nov 19 at 14:24
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374664%2fmy-dll-service-disappears-after-restarting-the-system%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Why don't you register the service using the API? Why hack at the registry?
– David Heffernan
Nov 19 at 13:37
@DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service to
svchost.exe– Mohammadreza Panahi
Nov 19 at 13:44
Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
– David Heffernan
Nov 19 at 13:56
@DavidHeffernan according this stackoverflow.com/questions/30554180/…
– Mohammadreza Panahi
Nov 19 at 13:58
Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
– David Heffernan
Nov 19 at 14:24