不是执行bat
是把批处理命令直接写到代码中

解决方案 »

  1.   

    可以是在代码中生成BAT文件,然后执行这个BAT.
      

  2.   

    System.Diagnostics.Process.Start("1.bat");
      

  3.   

    先用流把命令语句写到文本文件,保存为.bat文件,然后在执行.bat文件。
      

  4.   

    上面的方法都不是我想要的 我的意思是不要bat
    直接在代码中写 完全不要出现bat这个东西
      

  5.   

         Process p = new Process();
                p.StartInfo.FileName = "cmd";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.Start();
                StreamWriter sw = p.StandardInput;
                sw.WriteLine("regsvr32 /s TMNC_OCX.ocx");
                sw.Close();
                return true;
    要返回值吗???
      

  6.   

    上面的是一句命令。如果是两句是这么写的
    Process p = new Process();
      p.StartInfo.FileName = "cmd";
      p.StartInfo.UseShellExecute = false;
      p.StartInfo.CreateNoWindow = true;
      p.StartInfo.RedirectStandardInput = true;
      p.StartInfo.RedirectStandardOutput = true;
      p.Start();
      StreamWriter sw = p.StandardInput;
      sw.WriteLine("regsvr32 /s TMNC_OCX.ocx");
     sw.WriteLine("第二句命令");
      sw.Close();
      return true;