How to Install a Batch file as Windows Service
Especially for SAPRouter and other Batch programs sometimes needed to be run as a service on Windows based systems. For this, follow the below procedure
1. Download Windows 200x Resource Kit
For windows 2003: http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD
2. Install the Windows 200x Resource Kit
3. Create the service entry (here named as CS_URD4) with the below commands.
C:\>cd C:\Program Files\Windows Resource Kits\Tools
C:\Program Files\Windows Resource Kits\Tools>instsrv.exe CS_URD4 “C:\Program Files\Windows Resource Kits\Tools\srvany.exe”
The service was successfuly added!
Make sure that you go into the Control Panel and use
the Services applet to change the Account Name and
Password that this newly installed service will use
for its Security Context.
C:\Program Files\Windows Resource Kits\Tools>
4. Edit the Registry key created with REGEDIT.
Click on Start and type regedit > Ok > Find
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CS_URD4
Click Edit > Add Key and type Parameters, click OK
Double click on Parameters > Edit and choose Add Value
Add Value = Application
Data Type = REG_SZ
click Ok
String = D:\IBM\CSSAP\server\instance_URD\startURD.bat
click Ok
5. Double click on Parameters > Edit and choose Add Value
Add Value = AppDirectory
Data Type = REG_SZ
click Ok
String = D:\IBM\CSSAP\server\instance_URD
click Ok
6. Go to services again and Start the service CS_URD4