sc.exe how to set up the description for the windows Service?

C#Windows Services

C# Problem Overview


I am using sc.exe command to install C# windows service.

C:Windows\System32> sc.exe Create "TestService1" binPath= "C:\Program Files (x86)\Test\TestService1" DisplayName= "TestWindowsService1"

It created service. I was able to start the service. Many Instances I was able to create using sc.exe command

Looking at Services

Name | Description | Status | Start type | Log on As

Description section is blank, I would like to set the descriptionm, Any way to set up description for the service using sc.exe commmand?

C# Solutions


Solution 1 - C#

You need to call sc again to set the description. For example:

sc description TestService1 "This is the description of the service.."

For more information, see here.

Solution 2 - C#

Is not

sc description TestService1 "TestService1"

as per documentation: https://technet.microsoft.com/en-us/library/cc742069.aspx ?

Solution 3 - C#

For those experiencing "A positional parameter cannot be found that accepts argument" (PositionalParameterNotFound) error while trying to use the "sc description" command, replace sc with sc.exe. Apparently it fixes the problem, although the "sc create" command works as expected, without .exe

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsivaLView Question on Stackoverflow
Solution 1 - C#DonalView Answer on Stackoverflow
Solution 2 - C#ares777View Answer on Stackoverflow
Solution 3 - C#Alexey NagogaView Answer on Stackoverflow