Install a bat file or cmd script as service on a Windows Server machine.
To install a Bat file or CMD script as a Service we would need a small Microsoft utility called srvany.exe which is part of the Windows Server 2003 Resource Kit tools and can be downloaded free from Microsoft Download center here.
Steps:
· Download Windows Server 2003 Resource Kit tools from here and install it on any server.
· Create a folder on your server ex C:\YourServiceName
· Just copy srvany.exe to C:\YourServiceName from the location where Resource Kit tools were installed (usually C:\Program Files (x86)\Windows Resource Kits\Tools\), after this step Windows Server 2003 Resource Kit tools can be uninstalled as it is no longer needed.
· Launch CMD as Administrator.
· Type following Command which will install a service named YourServiceName on the server
sc create YourServiceName binpath= C:\YourServiceName\srvany.exe DisplayName= "Your Service Name"
· Open Registry editor by Clicking Start > regedit
· Navigate to following location and right click and create a New key named YourServiceName
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YourServiceName
· Right Click on YourServiceName and Create another key named Parameters under that.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YourServiceName\Parameters
· Under Parameters Right Click in the righthand pane and select New String Value named Application Under that.
· Double Click the String Value named Application mention the Path of your bat file/cmd script there.
At this point we are done and we can now start the service and set the mode of the service to Automatic/Manual or whatever we want as per our need and the service will keep running which in background will run the Batch file/CMD Script continuously.
No comments:
Post a Comment