Click here to Skip to main content
15,923,087 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I created Windows service. The service can be started/stopped manually only, but not through a .bat file (it used to work multiple years ago). The start.bat is written as below:
@ECHO OFF
ECHO Starting service!
SC START MyWinService

The .bat file is in ...\bin\debug\ folder, in which the myWinService.exe is stored.
How to resolve the problem? Thanks.

What I have tried:

Can't start an service through running a .bat file.
Posted
Updated 8-Sep-23 10:13am
v2
Comments
s yu 8-Sep-23 9:23am    
Referring to https://stackoverflow.com/questions/133883/stop-and-start-a-service-via-batch-or-cmd-file, Just revised the .bat as
net start [your service]
if %errorlevel% == 2 echo Could not start service.
if %errorlevel% == 0 echo Service started successfully.
echo Errorlevel: %errorlevel%
Then it works. Thanks for your review.

1 solution

Answered only to remove from "Unanswered" list - solved by OP.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900