Syntax for the "Start" method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg Smith

    #1

    Syntax for the "Start" method

    I am trying to use the "Ping" command and capture the
    output. I can run it with the following:

    System.Diagnost ics.Process.Sta rt("ping.exe", "-a
    123.123.123.123 ");

    This works fine. However, when I attempt to redirect the
    output to a file using:

    System.Diagnost ics.Process.Sta rt("ping.exe", " -a
    123.123.123.123 > c:\\temp\\ping. txt");

    This does not work. What would the correct syntax be for
    this?

    Any help is greatly appreciated.

    P.S. Is there any other way to capture this output into
    my program?


  • Chris Capel

    #2
    Re: Syntax for the "Start&quo t; method

    System.Diagnost ics.Process p = new System.Diagnost ics.Process();

    p.StartInfo.Fil eName = "ping";

    p.StartInfo.Red irectStandardOu tput = true;

    p.StartInfo.Arg uments = " -a 123.123.123.123 ";

    p.Start();

    p.WaitForExit() ;

    string output = p.StandardOutpu t.ReadToEnd();



    Chris

    "Greg Smith" <gjs@umn.edu> wrote in message
    news:0d0601c351 ec$e2d61b00$a40 1280a@phx.gbl.. .[color=blue]
    > I am trying to use the "Ping" command and capture the
    > output. I can run it with the following:
    >
    > System.Diagnost ics.Process.Sta rt("ping.exe", "-a
    > 123.123.123.123 ");
    >
    > This works fine. However, when I attempt to redirect the
    > output to a file using:
    >
    > System.Diagnost ics.Process.Sta rt("ping.exe", " -a
    > 123.123.123.123 > c:\\temp\\ping. txt");
    >
    > This does not work. What would the correct syntax be for
    > this?
    >
    > Any help is greatly appreciated.
    >
    > P.S. Is there any other way to capture this output into
    > my program?
    >
    >[/color]


    Comment

    • Yves Tourchot

      #3
      Re: Syntax for the &quot;Start&quo t; method

      try

      Process.Start(" cmd.exe", "/c ping.exe -a 123.123.123.123 >
      c:\\temp\\ping. txt");

      "Greg Smith" <gjs@umn.edu> wrote in message
      news:0d0601c351 ec$e2d61b00$a40 1280a@phx.gbl.. .[color=blue]
      > I am trying to use the "Ping" command and capture the
      > output. I can run it with the following:
      >
      > System.Diagnost ics.Process.Sta rt("ping.exe", "-a
      > 123.123.123.123 ");
      >
      > This works fine. However, when I attempt to redirect the
      > output to a file using:
      >
      > System.Diagnost ics.Process.Sta rt("ping.exe", " -a
      > 123.123.123.123 > c:\\temp\\ping. txt");
      >
      > This does not work. What would the correct syntax be for
      > this?
      >
      > Any help is greatly appreciated.
      >
      > P.S. Is there any other way to capture this output into
      > my program?
      >
      >[/color]


      Comment

      Working...