c#如何控制系统服务的重启!
解决方案 »
- C# socket 异步通信求解啊!!急!!在线等
- C# Linq多表查询不支持Jion 方法
- InstallShield2011如何让打包的程序附加上.net framework4?
- 进程通信,很奇怪 大家帮忙看看这段代码
- 在.NET下如何用代码实现锁定屏幕
- 菜鸟提问:C#写的产品分页问题 NO.1
- 在MDI 程序里 为了好调用把子窗提定义成静态的 好吗??对程序有什么影响
- 字符串“20050328”怎么转为“2005-3-28”
- MailMessage的使用,不能发txt附件????
- 未能加载类型库。库没有注册。这种错误怎么解决?
- 求助]如何获取当前程序的版本号?
- 【急】困扰我两天的强类型DATASET问题,麻烦知道的朋友告诉我
或者
类似ServiceController sc = new ServiceController();
sc.ServiceName = "W3SVC";
if (sc.Status == ServiceControllerStatus.Stopped)
{
// Start the service if the current status is stopped. Console.WriteLine("Starting the Alerter service...");
try
{
// Start the service, and wait until its status is "Running".
sc.Start();
sc.WaitForStatus(ServiceControllerStatus.Running);
// Display the current service status.
Console.WriteLine("The www 服务 status is now set to {0}.",
sc.Status.ToString());
}
catch (InvalidOperationException)
{
Console.WriteLine("Could not start the Alerter service.");
}
}
http://blog.csdn.net/zhzuo/archive/2004/03/21/22024.aspx
2.使用System.ServiceProcess.ServiceController 类来操作。
3.使用System.Wmi来访问控制,例子,
http://blog.csdn.net/zhzuo/archive/2004/03/29/22025.aspx