C#启动停止windows服务
来源:互联网 发布:linux 串口驱动 编辑:程序博客网 时间:2024/05/16 14:11
启动windows服务:
引用命名空间using System.ServiceProcess;
ServiceController cs1 = new ServiceController(); //建立服务对象
cs1.MachineName = "localhost";
cs1.ServiceName = servicename; // 服务名称
// 服务 停止则运行
if (cs1.Status == ServiceControllerStatus.Stopped
|| cs1.Status == ServiceControllerStatus.StopPending)
{
cs1.Start();
cs1.Refresh();
}
相应的,服务运行的情况下也可以停止服务。
if (cs1.Status == ServiceControllerStatus.Running)
{
cs1.Stop();
cs1.Refresh();
}
- C#启动停止windows服务
- C#启动,停止Windows服务
- windows启动停止服务
- c# windows服务状态、启动和停止服务
- C#对Windows服务操作(注册安装服务,卸载服务,启动停止服务,判断服务存在)
- delphi启动停止windows服务
- Web启动,停止Windows服务
- c#管理服务停止启动
- c#开启/停止Windows服务
- C# windows服务:通过cmd命令安装、卸载、启动和停止Windows Service(InstallUtil.exe)
- C# windows服务:通过cmd命令安装、卸载、启动和停止Windows Service(InstallUtil.exe)
- C# windows服务:通过cmd命令安装、卸载、启动和停止Windows Service(InstallUtil.exe)
- C# windows服务:通过cmd命令安装、卸载、启动和停止Windows Service(InstallUtil.exe)
- C# windows服务:通过cmd命令安装、卸载、启动和停止Windows Service(InstallUtil.exe)
- C#操作注册服务卸载服务启动服务停止服务..
- C#操作注册服务卸载服务启动服务停止服务.. .
- 命令行方式 启动和停止 windows服务
- windows命令:启动停止某个服务
- linux c编程 多线程(中级)
- How to distinguish between 32 and 64-bit JVM
- c++名词解释
- hibernate——配置测试
- Shell 学习4(通配符)
- C#启动停止windows服务
- EMOS问题处理2- slockd 垃圾邮件拦截
- extern用法
- C#启动windows服务浅析
- hibernate——对象状态
- 关于数组的一些简单操作
- C# 用Process启动系统资源
- 【Perl读书笔记】if语句和关系运算符
- ControlTier,基于命令的自动化部署工具