-
c#监控程序
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Diagnostics;
- namespace WhbServerTask
- {
- public partial class Form1 : Form
- {
- private string ExeName = "DOS_XXT";
- private string ExePath = @"E:DOS_XXT.exe";
- private bool RunFlag = false;
- private Process[] MyProcesses;
- public Form1()
- {
- InitializeComponent();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- whbtask();
- } private void whbtask()
- {
- listBox1.Items.Add(DateTime.Now.ToString() + ": " + " 程序轮询,运行正常!");
- MyProcesses = Process.GetProcesses();
- foreach (Process MyProcess in MyProcesses)
- {
-
- if (MyProcess.ProcessName.CompareTo(ExeName) == 0)
- {
- RunFlag = true;
- }
- }
- if (!RunFlag)
- {
- System.Diagnostics.Process.Start(ExePath);
- listBox1.Items.Add(DateTime.Now.ToString() + ": " + ExePath+" 程序重新启动一次!");
-
- }
- RunFlag = false;
-
- }
- private void button1_Click(object sender, EventArgs e)
- {
- listBox1.Items.Clear();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- listBox1.Items.Add("说明:本程序为" + ExePath + "的运行监控程序,每1小时轮询一次,如果" + ExePath + "异
- 常关闭,则自动重启该程序!");
- }
- }
- }
-
相关阅读:
jquery 删除cookie失效的解决方法
SQL Server 抛出自定义异常,由C#程序俘获之并进行相应的处理
SqlServer中的自增的ID的最后的值:
Stream/Bytes[]/Image对象相互转化
TextBox禁止复制粘贴和数字验证,小数验证,汉字验证
扩展WPF的DataGrid按方向键移动焦点
WPF 中获取DataGrid 模板列中控件的对像
IIS设置文件 App_Offline.htm 网站维护
IIS设置文件 Robots.txt 禁止爬虫
js中的整除运算
-
原文地址:https://www.cnblogs.com/liushunli/p/5019728.html
Copyright © 2020-2023
润新知