c#中如何调用一个带参数的命令行
System.Security.SecureString password = new System.Security.SecureString();            char[] pass = { 'w', 'd', 'o', 'w', 'n', 'e', 'r'};            for (int i = 0; i < pass.Length; i++)
            {                password.AppendChar(pass[i]);            }            password.MakeReadOnly();
            Process p = new Process();            p.Start("MHIdentificationFileSessionSample.exe", "wdowner", '"password"', "ExampleContent.mpg");执行MHIdentificationFileSessionSample.exe命令行,带参数用户名:wdowner 密码:password 第三个参数是ExampleContent.mpg。
这样做对吗

解决方案 »

  1.   

    Process p = new Process();
    p.StartInfo = new ProcessStartInfo(filename, argsments);
    p.Start();
      

  2.   

    Process.Start(filename, user, password, domain)
      

  3.   

      Process p = new Process(); p.Start("MHIdentificationFileSessionSample.exe", "wdowner",password, "ExampleContent.mpg"); 
    这样对吗
      

  4.   

    还没有碰到过这样的问题, 关注下 ,以前只是
    Process p = new Process(); 
    p.Start(); 
      

  5.   

    我现在要运行一个MHIdentificationFileSessionSample.exe命令,同时带三个参数:
    wdowner,password,ExampleContent.mpg  分别是用户名,密码,一个媒体文件本来是 命令行运行 
     MHIdentificationFileSessionSample.exe  wdowner  wdowner  ExampleContent.mpg
    现在我要在c#里用语句执行这个命令行,如何写
      

  6.   

    使用ProcessStartInfo类,有一个Arguements属性,用于向应用程序提供运行参数。
      

  7.   

    能具体些吗?应用程序: 
    MHIdentificationFileSessionSample.exe 
    三个参数 wdowner  wdowner  ExampleContent.mpg 
    现在我在c#里用语句执行这个命令行,如何用ProcessStartInfo写
      

  8.   

      System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.FileName = @"C:\\Program Files\\MediaHedge\\MHSDK\MHIdentificationFileSessionExample\\win\\MHIdentificationFileSessionSample.exe";  
                //参数用空格分开 
                startInfo.Arguments = @"wdowner"+" "+"wdowner"+" "+"C:\\Program Files\\MediaHedge\\MHSDK\\MHIdentificationFileSessionExample\\win\\ExampleContent.mpg";  
                System.Diagnostics.Process.Start(startInfo);  z怎么还是不行呢?
      

  9.   

    你在cmd里执行同样的命令可以么?
    楼上的代码肉眼看不出问题
    如果可以再检测Arguments属性里拼写
      

  10.   

    命令行执行:
    C:\\Program Files\\MediaHedge\\MHSDK\MHIdentificationFileSessionExample\\win\\MHIdentificationFileSessionSample.exe  wdowner wdowner C:\\Program Files\\MediaHedge\\MHSDK\\MHIdentificationFileSessionExample\\win\\ExampleContent.mpg执行成功。但是
     System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); 
    startInfo.FileName = @"C:\\Program Files\\MediaHedge\\MHSDK\MHIdentificationFileSessionExample\\win\\MHIdentificationFileSessionSample.exe";  
      //参数用空格分开 
    startInfo.Arguments = @"wdowner"+" "+"wdowner"+" "+"C:\\Program Files\\MediaHedge\\MHSDK\\MHIdentificationFileSessionExample\\win\\ExampleContent.mpg";  
     System.Diagnostics.Process.Start(startInfo);  不行。报错说MHIdentificationFileSessionSample.exe的用法错误
    为什么?
    我的Arguments 组合错了吗?
      

  11.   

    startInfo.Arguments = @"wdowner"+" "+"wdowner"+" "+"C:\\Program Files\\MediaHedge\\MHSDK\\MHIdentificationFileSessionExample\\win\\ExampleContent.mpg";  
    我的组合错了吗?
      

  12.   

    这样的组合应该是没有错,测试的结果是Arguements的值会按照空格分割成字符串数组。比如:using System;
    using System.Diagnostics;namespace ClassB
    {
      class B
       {
        public static void Main(string [] args)
         {
           if(args!=null)
           Console.WriteLine("有{0}个命令行参数",args.Length);
           Console.ReadKey();
         }
       }
    }可以正确输出参数的个数。
      

  13.   

    Process.Start(filename, user, password, domain)
      

  14.   

    process.Start("MHIdentificationFileSessionSample.exe", " wdowner  wdowner  ExampleContent.mpg ");