I added a windows service to run a custom program which is called from a batch file. So I added the service using sc and created it properly (I have done this before for other programs so I know the syntax).
The problem I have is in starting the service, I always get the error:
Code:
The service did not respond to the start or control request in a timely fashion.
Talk about an annoying and generic error...
I have checked the program path and args are valid, even tried several different incarnations of it. Every incarnation works if run from cmd. The command line is:
Code:
d:\dir1\dir2\start_program.bat
where the batch simply does a cd into it's current directory and then runs another program in that directory.
The exact line given above works, I have even changed user accounts to get it to work, let it run as the system account, but the same result. If I runas the above command it works, so the account details cannot be wrong or have permissions problems.
The thing bails out with an error immediately.
The batch is written to run in the foreground, not to fork and not to exit unless the service exits and then it reaches the end of the batch file.
All I can think of is that it is not valid to try to run a batch file as a service.
Does it take a special kind of program to run as a service, perhaps one that responds to certain system calls or something?
Or is there some similar limitation about the type of program or the stucture of a program that would stop it running as a service?