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();
                }
            }
  • 相关阅读:
    20171121
    20171117
    20171106
    20171031
    20171024
    20170924
    20170721
    商品的分类
    会员价格的修改
    会员价格删除
  • 原文地址:https://www.cnblogs.com/rhythmK/p/3110665.html
Copyright © 2011-2022 走看看