Can not start the service which was created with sc create command

Mahesh 21 Reputation points
2021-02-01T12:51:02.287+00:00

Hello Folks,

Simple service creation but can not start it with services tool

I want to make my batch file run as windows service, i tried below

sc create TestService1 displayname= "Test service 1" type= own error= severe obj= "LocalSystem" start= auto binpath= "C:\test\open-news.cmd"

Result
[SC] CreateService SUCCESS

But when i use services tool and start "TestService1"

62602-service-error.png

What could be issue? any idea how to make batch file as service?

Thanks.

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 36,401 Reputation points
    2021-02-01T13:44:23.017+00:00

    You cannot directly run a .cmd file as a service. The service executable needs to have service specific entry points compiled into it.

    To run a .cmd file you would need to use srvany.exe from the old NT Resource Kit (if you can find it) or use a tool like NSSM

    I recommend NSSM. https://nssm.cc/

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2021-02-02T06:57:02.327+00:00

    Hi,
    The discussion here in this thread might help:
    add a "\" before the binPath

    https://social.technet.microsoft.com/Forums/en-US/8c49c953-afe1-4876-94de-2c70936aeb7c/failed-to-create-service-via-sc-create-command?forum=winserverManagement

    Best regards.

    **
    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.