Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 2186 when starting batch file as service

Status
Not open for further replies.

cichlid

Technical User
Oct 11, 2000
61
GB
I've created a batch file that I want to run as a service.
I've used INSTSRV.EXE to install it as a service - all okay.
I've let it use the admin account and it has log on locally, log on as service and log on as a batch file.
Problem occurs when I try and start the service - always reports error 2186 - won't respond to the control function.
Event log reports that it doesnt respond in a timely fashion.
Can anyone tell me where to start?
Cheers.
 
first, are you installing the service using srvany?

instsrv.exe [servicename] srvany.exe

I know that you can set up a batch file as a service using srvany. The nt resource kit has a great .doc file on srvany. If you are already using srvany, then post the text of the batch file and the registry entry under:
HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\SERVICES\SERVICENAME

and i will take a look. . . .

David Moore
dm7941@sbc.com
 
Think that's what I was doing wrong - I'll give it a try using srvany and let you know how I get on.
Cheers.
Seán.
 
tried using srvany - got error 2140 - internal win nt error when trying to start it.
tried it with localsystem account (+interact with desktop) and tried it with an account that can logon as service, batch file and locally. still the same.
the batch file is only a test one - it copies a file from one place to another and then sleeps for 30 seconds.
registry entry is test\Paramaters\Application: REG_SZ: c:\mirror\test.bat
 
you might try running an application instead of a batch file. .just a quick check. I've never tried using sleep in a batch file from a service, but I also don't know any reason it should not work. Question. . does the file copy occur when you attempt the service startup?

David Moore
dm7941@sbc.com
 
file copy doesn't even kick off.
i tried to install it as an AT job but it just hogs the CPU and doent actually run proplery.
tried notepad.exe as the application - same result - starting to think it may need re service packed or something.
 
Well, it seems the problem is something with service starting. . .lets back up a bit. What is it you are actually trying to accomplish? David Moore
dm7941@sbc.com
 
just tried it with srvinstw - still no joy.
I have two machines - one is updated and a flag file dropped in - there is a batch file running that sleeps for 15 minutes and then checks for the flag file. if the flag file is there it zips up about 40mb of html files and ftp's them to the other machine. At the minute I am leaving the machines logged in but locked so that the batch file can be left running but I need to be able to get it to run in the background.
Do you have an alternative to this 'replication'?

Seán.
 
i'd go back to the AT command, but get rid of all the "sleep.exe" uses and schedule the batch file from AT to run every 15 min. That way it won't hog the CPU anymore, because it is not even running most of the time. If it was hogging the CPU when running from AT, then it would hog it just as much running as a service. If you need multiple pauses in the running, then make separate batch files for each segment. Then you can "schedule" the pauses. How does that sound?



David Moore
dm7941@sbc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top