sc.exe 如何设置 windows 服务的描述?

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

我正在使用 sc.exe 命令安装 C# windows 服务。

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

它创建了服务。我能够启动服务。我可以使用 sc.exe 命令

创建许多实例

查看服务

姓名 | 描述 |状态 |开始类型 |登录为

描述部分是空白的,我想设置描述,有什么方法可以使用 sc.exe 命令为服务设置描述吗?

不是

sc description TestService1 "TestService1"

根据文档:https://technet.microsoft.com/en-us/library/cc742069.aspx ?

您需要再次调用sc来设置描述。例如:

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

有关详细信息,请参阅 here

对于那些在尝试使用“sc description”命令时遇到“无法找到接受参数的位置参数”(PositionalParameterNotFound) 错误的用户,请将 sc 替换为 sc.exe。显然它解决了问题,尽管“sc create”命令按预期工作,没有 .exe