简体   繁体   English

ServiceController.Start(串[])

[英]ServiceController.Start(string[])

I'm trying to start a service that has a argument that specifies a port number. 我正在尝试启动具有指定端口号的参数的服务。 For example, using the DOS net I would do the following: 例如,使用DOS网络,我将执行以下操作:

net start "SERVICENAME" /"ARGUMENT"

How would I do the same in C# using Service.Controller.Start()? 我如何在C#中使用Service.Controller.Start()做同样的事情?

This should work: 这应该工作:

var sc = new ServiceController() { Name = "SERVICENAME" };
sc.Start(new string[] { "ARGUMENT" });
sc.WaitForStatus(ServiceControllerStatus.Running);

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

相关问题 无法在调用线程中捕获ServiceController.Start()异常 - Unable to catch ServiceController.Start() exceptions in calling thread ServiceBase OnStart不从serviceController.Start接收args - ServiceBase OnStart Not receiving args from serviceController.Start ServiceController.Start()未达到“正在运行”状态 - ServiceController.Start() don't reach “Running” status 无法使用ServiceController启动和停止服务 - Unable to start and stop service using ServiceController 使用ServiceController通过其他帐户启动服务 - Use ServiceController to start a service with a different account Windows 2016:ServiceController.DisplayName在Windows开始时返回ServiceController.ServiceName - Windows 2016: ServiceController.DisplayName returns ServiceController.ServiceName on Windows Start 如何在C#中使用ServiceController启动Windows Service的新实例 - How to start a new instance of Windows Service using ServiceController in C# 使用 C# ServiceController 和 Impersonation 启动/停止 windows 服务 - Start / stop windows services with C# ServiceController and Impersonation servicecontroller权限 - servicecontroller permissions C#ServiceController在查找使用参数而不是硬编码字符串时找不到服务 - C# ServiceController not finding service when lookup uses parameter instead of hardcoded string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM