Launching Any program as windows service

Posted on May 11, 2009. Filed under: Windows service | Tags: |

Most people find the windows services a reliable way for running the programs. Many software’s when installed adds the windows service through which one can start and stop that software. By means of services one need not to remember the installation directory and name of executable to start and stop(in some cases).

So obviously, one would like to have their executable running as windows services. For this purpose one can use windows Resource Kit.

Steps For Launching the any program as windows service:-

Prerequisite
Windows Resource kit.
Install resource kit to C:RESKIT Directory
(Note:- This is a example, user can install in any directory of his wish)
1. At a MS-DOS command prompt(running CMD.EXE), type the following command:C:RESKITINSTSRV.EXE My_Service_Name C:RESKITSRVANY.EXE

NOTE:- To verify that the service was created correctly, check the registry to verify that the ImagePath value under
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesMy_Service_Name
is set to point to SRVANY.EXE. If this is not set correctly, the service will stop shortly after it starts and return an Event ID 7000 “The service name failed to start.”

2. Run Registry Editor (Regedt32.exe)and locate the following subkey:

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesMy_Service_Name

3. From the Edit menu, click Add Key. Type the following and click OK
Key Name: Parameters

4. Select the Parameters key.

5. From the Edit menu, click Add String Value. Type the following and click OK
Value Name: Application
Data Type : REG_SZ
String : pathapplication.ext

where “pathapplication.ext” is the drive and full path to the application executable including the extension

6. From the Edit menu, click Add String Value. Type the following and click OK:
Value Name: AppDirectory
Data Type : REG_SZ
String : path

where “path” is the drive and full path to directory where the application application resides

7. Close Registry Editor.

8. Starting / Stopping service
- From the Services applet in Control Panel
- From a MS-DOS command prompt, type the following:
NET START My_Service_Name
NET STOP My_Service_Name

9. Testing whether My_Service_Name is started or not
Open task manager. Go to process tab.
When service is started then there should be two processes running “srvany.exe” and “My_Service_Name.exe”

10. Removing service
Open command prompt and run command

C:RESKITINSTSRV My_Service_Name remove

This task involves editing registry, which may cause any side effect if person do not have proper knowledge of it. So be sure that you know some basics of registry editing.

Advertisement

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

Follow

Get every new post delivered to your Inbox.