Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Redirecting outputs if Process.Start is used.

Redirecting outputs if Process.Start is used.

Scheduled Pinned Locked Moved C#
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cadence2 0
    wrote on last edited by
    #1

    Hi! Is it possible to redirect the output from Process.Start to a textfile or (even better) a variable? I'm using Process.Start to invocate ipconfig to get the mac address.. Thanks in advance,

    -K

    E 1 Reply Last reply
    0
    • C Cadence2 0

      Hi! Is it possible to redirect the output from Process.Start to a textfile or (even better) a variable? I'm using Process.Start to invocate ipconfig to get the mac address.. Thanks in advance,

      -K

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      Use Process Start Info to indicate that the process will redirect its std out, in , and err then on then create a process object with the start info as a parameter. Set event listeners on the process for the 3 streams and viola.

      A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

      C 1 Reply Last reply
      0
      • E Ennis Ray Lynch Jr

        Use Process Start Info to indicate that the process will redirect its std out, in , and err then on then create a process object with the start info as a parameter. Set event listeners on the process for the 3 streams and viola.

        A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

        C Offline
        C Offline
        Cadence2 0
        wrote on last edited by
        #3

        Bien! Just what I wanted. Thanks a million...:-D

        -K

        C 1 Reply Last reply
        0
        • C Cadence2 0

          Bien! Just what I wanted. Thanks a million...:-D

          -K

          C Offline
          C Offline
          Cadence2 0
          wrote on last edited by
          #4

          Process p = new Process(); // Redirect the output stream of the child process. p.StartInfo.UseShellExecute = false; //p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = "ipconfig.exe"; p.StartInfo.Arguments = ("/all"); p.StartInfo.RedirectStandardOutput = true; p.Start(); p.WaitForExit(); string s = p.StandardOutput.ReadToEnd(); Console.WriteLine(s); Console.ReadKey();

          -K

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups