Running a bat file in XP as a windows service

batch-filewindows-servicewindows-xp

Im using Windows XP and i want to run a particular bat file as a windows service.Is there any way to do that ?

Please Help
Thank You

Best Answer

You can use the sc command. For example, from a command prompt:

sc create MyService binPath= "C:\Program Files\Windows Resource Kits\Tools\Srvany.exe" DisplayName= "My Windows Service"

To remove:

sc delete Service

Now, the service created is using Srvany.exe, which is part of the Windows Resource Kit. This enables you to define a service with your software that otherwise would not support it.

After that, you will need to use RegEdit to create a "Parameters" key for your service under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\. Within that key, you will want to create a string value called "Application" and enter the full path to your batch file that you want to run as a service.

Microsoft has instructions for this as well using a different method to create the service initially.