How to run an application as a service (Creating a User-Defined Service). – wintips.org

If you want to run the program as a Service on Windows, continue reading this guide. As you know, the common ways to run a program at Windows Startup are to place the program in the Windows Startup folder, or to run the program at startup using the Windows Registry, or to run the program using the Task Scheduler. Although these methods are effective in most cases, in some cases it is necessary to run the application as a Windows service at startup, before user logon or user interaction.

This guide contains step-by-step instructions on how to create a Windows service with any application on Windows 10, 8, 7 and Server OS.

How to run any program as a Windows service.

Method 1. Run the program as a Windows service using the RunAsService utility.
Method 2. Run the application as a service using the NSSM utility.

Method 1. How to run any program as a Windows service with the Run as Service utility.

The first way to create a user-defined service from any program is to use the RunAsService utility.

1. Download Download the RunAsService tool to your computer.
2. Transfer or Copying downloaded file RunAsService.exe, to the root folder of the C:\ drive. *

* Note (Important): You can place the RunAsService.exe tool anywhere on your disk, but keep the tool in the same location so that installed services continue to run.

Run as a Windows service

3. It’s open Command line as administrator.
4. In the command line, type: cd\

5. Now install the desired application as a service using the following command: *

  • Install RunAsService”Service name“”Display name PathToExecutable

Notes:

1. In the command above replace it the values inside red letters as follows:

Name: Enter the name of the Service you want to create. you can use Service name manually start or stop the service by issuing the “net start” or “net stop” commands in the future.

Display name: Optionally, enter a different name for the list of Windows services. This is how the service name is displayed in the list of services. If “Display Name” is not specified, then the displayed name will be the same as the “Service Name” of the service you created.

PathToExecutable: Enter the full path of the application you want to run as a Windows service.

For example: Run the following command to install Notepad.exe as a Windows service named Notepad:

  • RunAsService Installs Notepad “C:\Windows\System32\notepad.exe”

RunAsService installation service

2. If after executing the above command you get the message “The application requires the .Net Framework 2.0 feature to run”, click the button. Download and install this feature, or download the .Net Framework 2.0 from the Microsoft Download Center.

image

6. After the command is executed, a new Windows service will appear in the list of services with the name specified in the “RunAsService” command. To run the newly created service on startup:

a. Right click in service and select Characteristics.

List of services

b. Make sure of it Launch type is set to Automatic.

image

c. Restart your PC to test the service. *

*Notes:
1. You can start or stop the service at any time by running the “net start” or “net stop” commands on the command line (Administrator).
2. If you want to remove the installed service in the future:

a. Stop the service by running this command Administrator command line:

for example net stop “Notepad”

b. Uninstall the service by issuing this command:

  • Disable RunAsService”Service name

for example RunAsService deletes “Notepad”.

RunAsService shutdown service

Method 2. Run any application as a service using NSSM.

The second way to run any program as a service in Windows is this Unsolicited service manager instrument.

1. Download NSSM.
2. Extract the downloaded ZIP file.
3. Change the name to the extracted folder (eg “nssm-2.24”), to NSSM.
4. Copying the NSSM to the folder root driver folder C:\
5. It’s open Command line as administrator and go to NSSM open the folder, enter the following commands in sequence (click Enter after entering each command):

6. Now, according to your version of Windows (32 or 64 bit), enter the appropriate command (and press the button) and go to one of the two subfolders. Enter).

  • If you have a 64-bit Windows system, type: CD win64
  • If you have a 32-bit Windows operating system, type: CD win32

7. Now enter the following command: *

Install nssm service

8. In the window that opens:

8a. Click the next tree (3) dot button image for THE WAY and select the executable file of the application you want to run as a service.

Installer of NSSM service

8b. When finished, type a Name and click for new service Installation of the service.

Install the service with NSSM

8c. press OK to the “Service successfully installed” message and you’re done! *

*Notes:
1. After installing the service with the NSSM service installer, a new Windows service with the name specified in the Service name appears in the list of services, which can be managed like any other Windows service.
2. To disable the service in the future:

a. Follow steps 5 and 6 above and then type the following command: *

*Note: where Service name = the name of the service you created using the NSSM utility.
for example Remove nssm NOTEPAD in this example.

nssm removal service

b. Finally click Yes to disable the service.

How to run an application as a service

That’s it! Let me know if this guide helped you by leaving a comment about your experience. Please like and share this guide to help others.

If you found this article useful, please support us by donating. Even $1 can make a big difference for us We continue to help others while keeping this site free:

Leave a Comment