Avatar of IDPInc
IDPInc asked on

Run a Batch File as a Service (troubleshooting)

I've gone through the following steps to have a batch file run as a service:

1. get the "srvany.exe " from the "Windows Server 2003 Resource Kit Tools " and copy it to a suitable location on your Win2008 server (e.g. C:\Windows\System32\ ).
2.Use "sc " to create a new service that launches "srvany " (e.g. sc create MyService binPath= C:\Windows\System32\srvany.exe DisplayName= "My Custom Service" )
3.Using RegEdit : create a "Parameters " key for your service (e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\Paramaters\ )
4.Using RegEdit : within the newly created "Parameters " key , create a string value called "Application " and enter the full path to the application you are wanting to run as a service.  (No quotes required.)

I tried using instrv in place of srvany.

When I try to start the service I get the error "Service did not respond to the start or control request in a timely fashion"

I played with the settings in the registry to change the "Path to Executable" but still no joy.  

The event viewer wasn't very help ful and when I ran an SC query i received:

C:\>sc query csss4

SERVICE_NAME: csss4
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
                                (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN))

        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Any ideas?
Windows Server 2003

Avatar of undefined
Last Comment
IDPInc

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
x-men

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Don

What is it that your batch is running?
ASKER
IDPInc

GOT IT!  

I was creating the PARAMETERS registry key in the wrong part of the tree.  Once I got it in the root justunder the service name it worked.  Any idea how to add something in the description field?  I tried to add a RegSZ similar to one of the other entries but it didn't work.  
ASKER
IDPInc

Wow, all of the instructions out there to edit the description are needlessly complicated when a single command line of:

C:\>sc description SERVICENAME "ENTERDESCRIPTIONHERE"

is all it takes.  I want to thank all of the programmers out there who make stuff way more complicated than it has to be.  Especially for people like me who suck at command line stuff.  
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck