后台点击按钮 调用控制台程序 传参数

来源:互联网 发布:微信生鲜小程序源码 编辑:程序博客网 时间:2024/05/28 06:04

1、按钮事件

try

        {
            Process pro = new Process();
            pro.StartInfo.FileName = this.UpgradeSeo;  //要调用的控制台程序   
            pro.StartInfo.Arguments = "1";
            pro.StartInfo.CreateNoWindow = false;     //控制显示窗口    
            pro.StartInfo.UseShellExecute = false;
            pro.Start();
            //pro.WaitForInputIdle();
            pro.WaitForExit(60000);
            if (pro.HasExited == false)
            {
                pro.Kill();

            }
            else
            {
                Response.Write("由外部程序正常退出!");
            }
            BindData();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);

        }

2、控制台代码

static void Main(string[] args)
        {
            DataTable dt = PRC_CategoryRules.GetAll();
            string seotype = args[0];//获取参数值
            foreach (DataRow dr in dt.Rows)
            {


原创粉丝点击