C#Windows服务自动和关闭 需求:在某个时间节点上自动关闭windows服务 if (DateTime.Now > Convert.ToDateTime("2020/09/12 00:00")) { ServiceController sc = new ServiceController("TxtToExcel"); if (sc.Status.Equals(ServiceControllerStatus.Running)) { sc.Stop(); sc.Refresh(); } }