Monday 3 December 2018

ruby - How to run script as a Windows XP service?


I want to run my ruby web server as a Windows XP service.


Somebody can advice how to do that?




I changed (removed the word ruby) the title so more people can find the answer. It will work for any kind of script.



Answer



I am editing a document I created and published to the web for another difficult problem, and adapting it to your question. I cannot be 100% sure that the Resource Kit tools will work with XP, but I believe they probably will.


1) Create a batch file to run your script and start your Ruby server. To be frank, I don't have enough info to tell you how to do that. Copy the batch file to a safe place like c:\windows\system32


2) Download the Windows 2003 Resource kit and install it to a directory with NO spaces, not the default in “C:\Program Files”. Use C:\RESOURCEKIT, as I will use it for the rest of the document. This is very important for some programs, which don't understand the space in “C:\Program Files”, but not for others...to be safe, put it here.


3) Open a command prompt, and change to the directory where you installed the Windows 2003 resource kit, in this case, C:\RESOURCEKIT.


4) From that directory, install the script as a service with the following command “instsrv YourServiceName C:\RESOURCEKIT\srvany.exe.” without the quotes around it. You can name the service any reasonably not-too-long name you like, and this will appear in the Services.msc. This should return “The service was successfully added!” Next we have to configure the new YourServiceName service.


5) Open the Registry editor to the [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YourServiceName] key.


6) Right-click on the YourServiceName key and do “New>Key” and name it Parameters (case sensitive).


7) Expand the new Parameters key and in the right pane right-click and do “New>String Value” and name it Application (case sensitive).


8) Double-click your new “Application” key and enter c:\windows\system32\YourBatchFileName.bat and save it. The service is now ready to run.


9) Test run it from within the Control Panel>Administrator Tools>Services MMC. You will see the service YourServiceName now listed and you can start it.


Here is a copy of my original article: http://www.eggheadcafe.com/microsoft/Windows-Server-Networking/30399980/solution-to-have-a-persistent-vpn-start-automatically-on-boot.aspx


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...