[英]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.