using System.ServiceProcess; //默认没有引用,需手动添加引用
- ServiceController service = new ServiceController("nginxd");
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (service.Status == ServiceControllerStatus.Running)
- {
- service.Stop();
- service.WaitForStatus(ServiceControllerStatus.Stopped);
- }
- service.Start();
- service.WaitForStatus(ServiceControllerStatus.Running);
- MessageBox.Show("nginxd服务重启成功");
- }
- catch (Exception)
- {
- }
- }
亲爱的:被墙域名跳转TG:@qianhenetwork QQ:851617266,可否收藏+评论+分享呢?
文章评论 本文章有个评论