繁体   English   中英

来自命令行的Windows服务自定义命令

[英]Windows service custom commands from command line

我已经实现了一个Windows服务,其自定义命令覆盖了OnCustomCommand方法。

我可以从另一个.net应用程序访问这些自定义命令:

ServiceController Controller = new ServiceController("MyWindowsService");
if (Controller.Status == ServiceControllerStatus.Running)
  {
      Controller.ExecuteCommand(128);
  }

但是,我可以从命令行(cmd)访问这些自定义命令,就像我可以启动/停止/ ...服务一样吗?

编辑:(没有创建中间件应用程序来处理服务,只需使用标准工具)

您可以使用服务控制命令行工具sc

> sc control MyWindowsService 128

(在引擎盖下,一切都使用Win32的ControlService API。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM