---
# System prepended metadata

title: dotnet consol app as service
tags: [dotnet]

---

---
title: dotnet consol app as service
tags: dotnet
---

To make a .NET Core console app run as a service, you can use the `sc` command in Windows to create a new service that runs the app. Here's an example of how you can do this:

1.  Open the Command Prompt and navigate to the directory where your .NET Core console app is located.

2.  Use the `sc` command to create a new service for your app. The syntax for this command is:

`sc create <service_name> binPath= "<path_to_your_app> <arguments>"`

For example, if your app is named `MyConsoleApp` and it is located in the `C:\MyApps` directory, you can use the following command to create a new service for it:

`sc create MyConsoleApp binPath= "C:\MyApps\MyConsoleApp.exe"`

Once the service has been created, you can start it using the `net start` command. For example, if your service is named `MyConsoleApp`, you can start it using the following command:

`net start MyConsoleApp`

You can also stop the service using the `net stop` command. For example, if your service is named `MyConsoleApp`, you can stop it using the following command:

`net stop MyConsoleApp`

Keep in mind that this is just one way to make a .NET Core console app run as a service. There are other ways to do this, such as using the `dotnet-servic` tool or creating a Windows Service project in Visual Studio.