zoukankan      html  css  js  c++  java
  • c#调用外部程序

     private System.Timers.Timer m_timer;
       
        void Application_Start(object sender, EventArgs e)
        {
            m_timer = new System.Timers.Timer(1000);
            m_timer.Enabled = true;
            m_timer.Elapsed += new System.Timers.ElapsedEventHandler(m_timer_Elapsed);  //事件代理
            //开启时钟。
            m_timer.Start();

        }       

    //定时执行 事件

     private void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs args)
        {

    string mypath = "cd " + HttpRuntime.AppDomainAppPath;
            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = true;
            p.Start();
           // p.StandardInput.WriteLine("c:");
            p.StandardInput.WriteLine(mypath);
            p.StandardInput.WriteLine("s.pl");
            p.StandardInput.WriteLine("md ok8");
            p.StandardInput.WriteLine("exit");
            string myreult = p.StandardOutput.ReadToEnd();
            p.Close();
            File.WriteAllText(@"C:\re.txt", myreult);

    }

  • 相关阅读:
    「2019纪中集训Day20」解题报告
    PHP基础入门
    javascript
    正则表达式
    DOM 节点
    对象
    字符串
    函数
    for循环
    jQuery
  • 原文地址:https://www.cnblogs.com/a311300/p/1806420.html
Copyright © 2011-2022 走看看