0

I created a Win32Console application using MSVS2013 and it was compiled successfully. Now I tried creating a service using CreateService and binary path was set to the path of the above produced executable. Though I was able to create the service, I cannot start it using StartService. The error code 1053 is thrown each time. I tried using sc.exe and also tried to start the service manually from Services. The same error is shown. How can I solve it now?

Jackzz
  • 1,417
  • 4
  • 24
  • 53
  • 2
    possible duplicate of [Convert a C++ program to a Windows service?](http://stackoverflow.com/questions/1554047/convert-a-c-program-to-a-windows-service) – NathanOliver Jun 02 '15 at 12:46
  • @0123456789: No..its just a `C++` application.Can I convert this exe to service?or start this exe from a service? – Jackzz Jun 02 '15 at 12:48
  • @NathanOliver: I have gone through that question several times.But was not sure how to implement it.. – Jackzz Jun 02 '15 at 12:51
  • @Jackz Can you give an [SSCCE](http://sscce.org) that gives the same behavior. – NathanOliver Jun 02 '15 at 12:55
  • @NathanOliver: U mean example of creating the `exe`?a simple C++ application? – Jackzz Jun 02 '15 at 12:57
  • @Jackz I am saying that if you followed the link provided in my dupe suggestion and you are getting the 1053 error then can you provide the code that you used to generate the service. Don't post all of the code but the minimum necessary to duplicate the problem. – NathanOliver Jun 02 '15 at 13:02
  • @NathanOliver: I couldn't completely get the info provided in that link. Must be because of my low knowledge in `Services` and and its implementation. Will try it tonight. – Jackzz Jun 02 '15 at 13:06
  • An ordinary application is not a service and cannot be directly used as one. You can either rewrite the application so that it is a service, or make use of a third-party service that runs applications, e.g., srvany or NSSM. – Harry Johnston Jun 03 '15 at 00:11

2 Answers2

0

You must create a ServiceMain.
Here is a sample.
If you want to execute a non-service application you can use psexec.

Paulo Alves
  • 388
  • 5
  • 14
0

You have collision with SC- manager and your function inside application start service

your name of the function service dispatcher table for service;) prevent from error 1053 if call was send not from SC - manager C++ code:

if(argc < 2)           
  {
     if(!Service_Dispatcher_Table())            
     {
       std::cout<<"ERROR :"<< GetLastError();
     }
 }
 else
 { 
     //your command line "argc" 
 }  

//here your commands or function : startservice();

Gra8
  • 1