zlzyp 发表于 2018-6-17 13:39:24

C#编写windows服务

private void timer1_Tick(object sender, EventArgs e)  {
  if (DateTime.Now.ToShortTimeString().CompareTo(DateTime.Parse("23:00:00")) > 0)
  {
  System.Diagnostics.Process pro = new Process();
  pro.StartInfo.FileName = "cmd.exe";
  pro.StartInfo.UseShellExecute = true;
  pro.StartInfo.RedirectStandardInput = true;
  pro.StartInfo.RedirectStandardOutput = true;
  pro.StartInfo.RedirectStandardError = true;
  pro.StartInfo.CreateNoWindow = true;
  pro.Start();
  pro.StandardInput.WriteLine("shutdown -s -t 0");
  }
  }
  写完之后我们在设计视图上单击右键选择“添加安装程序”,出现了两个installer。如下
页: [1]
查看完整版本: C#编写windows服务