How do you install a .NET 6 Windows Service (Worker Service) using a Visual Studio Installer project?

Viewed 1727

I Have a Worker Service written in c# that needs to be installed as a Windows Service (configured by calling the UseWindowsService method).

This guide specifies how to create an installer for a .NET 6 application, but this installer only copies the app's files.

How can I install the service contained in the executable?

1 Answers

You can use sc create command in order to register service. Like this:

sc.exe create NewService binpath= c:\windows\system32\NewServ.exe

P.S. pay attention, there is mandatory space after binpath=

Related