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();
                }
            }
  • 相关阅读:
    shell 算术运算符
    shell 关系运算符
    shell 布尔运算符
    shell逻辑运算符
    shell 字符串运算符
    shell 文件测试运算符
    shell 运算符
    shell 循环总结
    Shell echo命令
    利用WHID为隔离主机建立隐秘通道
  • 原文地址:https://www.cnblogs.com/rhythmK/p/3110665.html
Copyright © 2011-2022 走看看