简体   繁体   中英

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:

net start "SERVICENAME" /"ARGUMENT"

How would I do the same in C# using Service.Controller.Start()?

This should work:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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