Brain-Cluster.com Brain-Cluster.com is a free blogging website to share all sort of technical issue, article, How-to, latest news, etc.

9Feb/111

Run Application as Windows 2008 Service

Run Application as Windows 2008 Service

Windows 2008 do not provide toolkit similar like SrvAny and InstSrv that allow you to wrap the application and run as Windows Services.

Solution

  1. Download Windows 2003 Resource Kit from Microsoft http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en
  2. Install the the Windows 2003 Resource Kit into any workstation or even Windows 2008 server. We only need the SrvAny.exe file from the resource kit
  3. Copy SrvAny.exe in C:\Windows\System32 of Windows 2008 Server
  4. Use "sc " to create a new service that launches "srvany " (e.g. sc create MyCustomService binPath= C:\Windows\System32\srvany.exe DisplayName= "My Custom Service" )
  5. Using RegEdit : create a "Parameters " key for your service (e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyCustomService\Paramaters\ )
  6. 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.)

Example:

Below is the steps to make Inadyn (Simple Dynamic DNS client) to run as service

1. Download inadyn http://www.inatech.eu/inadyn/ (for OpenDNS, please download from http://www.opendns.com/support/ddns_files/inadyn-win32.zip)

2. Extract inadyn into c:\inadyn and do the necessary configuration by editing inadyn.conf

3. Copy SrvAny.exe from fron Windows 2003 Resource Kit into C:\Windows\System32

4. Create the service by the following command in command prompt

sc create inadyn binPath= c:\Windows\System32\srvany.exe DisplayName= inadync start= delayed-auto

5. Adjust the registy key. Below is the sample registry file. Just save the following content into anyfile.reg and then double-click to file to import it into registry.

REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\inadyn\Parameters]
; Edit the next line to show the full path to the inadyn.exe executable file. Note that any backslashes "\" in the path must be _doubled_ "\\"
"Application"="C:\\inadyn\\inadyn.exe"
; Edit the next line to replace "username" and "password" with your OpenDNS user name and password. The "--alias" string is arbitrary, and is really only relevant to more complex setups
"AppParameters"="--input_file C:\\inadyn\\inadyn.conf"

6. Completed. You should be able to see th inadyn in the Windows Services.

Reference:

http://www.opendns.com/support/article/190

%d bloggers like this: