82

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?

sivaL
  • 1,812
  • 5
  • 21
  • 30
  • 5
    After you create the service, call "sc description [service name] [description]" to set the description. – Jon Apr 17 '15 at 15:01

3 Answers3

160

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.

Donal
  • 31,121
  • 10
  • 63
  • 72
  • 6
    I find it weird that it wouldn't be a parameter in the create command. This works though, thanks. I'm hoping in the future MS beefs up the Worker Service template to allow these things to be set through code rather than command line. – Zoey Mar 23 '21 at 17:42
  • 2
    For those who would like to do this programmatically: `ChangeServiceConfig2A( service, SERVICE_CONFIG_DESCRIPTION, &desc );` – Bram Dec 27 '21 at 19:10
18

Is not

sc description TestService1 "TestService1"

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

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
ares777
  • 3,590
  • 1
  • 22
  • 23
3

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

Alexey Nagoga
  • 181
  • 1
  • 6