zoukankan      html  css  js  c++  java
  • 常用工具小方法

      static void GetServiceState()
            {
              
                /* 描述: 启动服务
                 * 添加引用:
                   using System.ServiceProcess;
                   using System.Management;
                 */
                const string ServiceName = "SQLSERVERAGENT";
                Console.WriteLine(string.Format("启动服务:{0}", ServiceName));
                //ManagementObject wmiService = new ManagementObject(string.Format("Win32_Service.Name='{0}'", ServiceName));
                //ManagementBaseObject changeMethod = wmiService.GetMethodParameters("Change");
                //changeMethod["DesktopInteract"] = true;
                //ManagementBaseObject OutParam = wmiService.InvokeMethod("Change", changeMethod, null);
    
    
                /*  启动服务代码 */
                ServiceController sc = new ServiceController(ServiceName);
    
                if (sc.Status.Equals(ServiceControllerStatus.Stopped))
                {
                    sc.Start();
                }
            }
  • 相关阅读:
    git使用
    silverlight与wcf双向通讯 例子
    Oracle 存储过程
    C# 视频教程
    佩服的技术大牛 “赵劼”
    setTimeout setInterval
    js闭包
    MVC Razor视图引擎控件
    MVC json
    springboot创建多环境profile打包
  • 原文地址:https://www.cnblogs.com/rhythmK/p/3110665.html
Copyright © 2011-2022 走看看