用Process.Start,其实只需执行
arj a c:\bak\0610-15.arj c:\bak\0610-15.doc
del c:\bak\0610-15.doc
即可(See more in msdn)

解决方案 »

  1.   

    ProcessStartInfo psi = new ProcessStartInfo();
    psi.FileName = "cmd.exe"; string systemDirectory  = System.Environment.SystemDirectory;
    string commandString = "/c yourcmd.cmd";
    psi.Arguments = commandString; Process proc = Process.Start(psi);
    proc.WaitForExit( );

    File.Delete(systemDirectory + "\\yourcmd.cmd");
    }
    catch(Exception ex)
    {
    throw ex;
    }
      

  2.   

    string fileFullName = @"C:\arjcmd.bat";
    string CrLf = "\r\n";
    string fileBody = "" + 
    @"@echo off" + CrLf +
    @"cd /d c:\bak" + CrLf + //注意这里的 /d 参数挺重要的
    @"arj a c:\bak\0610-15.arj c:\bak\0610-15.doc" + CrLf +
    @"del c:\bak\0610-15.doc" + CrLf +
    @"exit";FileStream ObjFile = new FileStream(fileFullName,FileMode.Create,FileAccess.Write,FileShare.None);
    StreamWriter sw = new StreamWriter(ObjFile,System.Text.Encoding.GetEncoding("GB2312"));
    sw.Write(fileBody);
    sw.Close();
    ObjFile.Close();Process.Start(fileFullName);
      

  3.   

    请问楼上的,Process.Start运行的时候弹出的cmd黑框怎么屏蔽掉不显示?
      

  4.   

    Process.Start(fileFullName);换成Process p = new Process();
    p.StartInfo.FileName = fileFullName;
    p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //就是它
    p.Start();就可以隐藏窗口
      

  5.   

    using System;
    using System.Threading;
    using System.Diagnostics;
    using System.IO;namespace arjcmd
    {
    class Class1
    {
    static void Main(string[] args)
    {
    string fileFullName = @"C:\bak\arjcmd.bat";
    string CrLf = "\r\n";
    string fileBody = "" + 
    @"@echo off" + CrLf +
    @"cd /d c:\bak" + CrLf + //注意这里的 /d 参数挺重要的
    @"arj a c:\bak\0610-15.arj c:\bak\0610-15.doc" + CrLf +
    @"del c:\bak\0610-15.doc" + CrLf +
    @"exit"; FileStream ObjFile = new FileStream(fileFullName,FileMode.Create,FileAccess.Write,FileShare.None);
    StreamWriter sw = new StreamWriter(ObjFile,System.Text.Encoding.GetEncoding("GB2312"));
    sw.Write(fileBody);
    sw.Close();
    ObjFile.Close();
                            Process.Start(fileFullName);
    } }
    }编译:
    C:\csc>csc c:\csc\arjcmd\class1.cs提示错误:
    arjcmd\Class1.cs(26,25): error CS0246:
            找不到类型或命名空间名称“Process”(是否缺少 using 指令或程序集引用?)process 不是在Diagnostics里吗!?
    为什么?????????????????
      

  6.   

    csc /r:System.dll  c:\csc\arjcmd\class1.cs
      

  7.   

    ok了!
    谢谢各位老兄!
    再问一下,如果我想让class1.exe在其他机器上运行,需要那些dll文件,怎么得到,怎么安装!