/// <summary>
/// 启动服务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
ServiceController sc = new ServiceController("WindowsService1");
if (sc.Status.Equals(ServiceControllerStatus.Stopped))
{
sc.Start();
}
}
/// <summary>
/// 停止服务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
ServiceController sc = new ServiceController("MSSQLSERVER");
用C#代码来安装、卸载、启动、关闭服务
最新推荐文章于 2024-06-07 14:00:51 发布