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
  1. Home
  2. General Programming
  3. C#
  4. cmd.exe standardinput problem, please help?!?!

cmd.exe standardinput problem, please help?!?!

Scheduled Pinned Locked Moved C#
helpperformancequestion
5 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.
  • D Offline
    D Offline
    Druuler
    wrote on last edited by
    #1

    I have very weird problem with the windows command prompts standard input. When i write regular dos command like cd or dir to the input stream everything goes as expected BUT when i want to execute a GUI app (say notepad) the window doesnt show up until i write some empty lines to the stream?:confused:

    cmd.StandardInput.WriteLine("notepad");
    cmd.StandardInput.Flush();
    //notepad windows hanst shown up and will not show up untill
    //i write empty lines/thrash to the input strem, btu the process notepad.exe is started with memory on ~1300 kb

    cmd.StandardInput.WriteLine("blaaaaa");// notepad.exe's mem goes to 2000+ kb
    cmd.StandardInput.WriteLine("blaaaaa");// notepad.exe's mem goes to 3000+ kb
    cmd.StandardInput.WriteLine("blaaaaa");// and finally notepads window shows up

    //allright, the notepad window is up now after i wrote those 3 lines but why is this happning?
    //if i want to start visualstudio form cmd by writing to its input stream i have to write 5+ lines to //the stream

    Please help..this is so weird, even my friend google couldnt help me :omg:

    1 1 Reply Last reply
    0
    • D Druuler

      I have very weird problem with the windows command prompts standard input. When i write regular dos command like cd or dir to the input stream everything goes as expected BUT when i want to execute a GUI app (say notepad) the window doesnt show up until i write some empty lines to the stream?:confused:

      cmd.StandardInput.WriteLine("notepad");
      cmd.StandardInput.Flush();
      //notepad windows hanst shown up and will not show up untill
      //i write empty lines/thrash to the input strem, btu the process notepad.exe is started with memory on ~1300 kb

      cmd.StandardInput.WriteLine("blaaaaa");// notepad.exe's mem goes to 2000+ kb
      cmd.StandardInput.WriteLine("blaaaaa");// notepad.exe's mem goes to 3000+ kb
      cmd.StandardInput.WriteLine("blaaaaa");// and finally notepads window shows up

      //allright, the notepad window is up now after i wrote those 3 lines but why is this happning?
      //if i want to start visualstudio form cmd by writing to its input stream i have to write 5+ lines to //the stream

      Please help..this is so weird, even my friend google couldnt help me :omg:

      1 Offline
      1 Offline
      12Code
      wrote on last edited by
      #2

      add cmd.StandardInput.Close(); after

      Druuler wrote:

      cmd.StandardInput.WriteLine("notepad"); cmd.StandardInput.Flush();

      ;)*12Code

      D 1 Reply Last reply
      0
      • 1 12Code

        add cmd.StandardInput.Close(); after

        Druuler wrote:

        cmd.StandardInput.WriteLine("notepad"); cmd.StandardInput.Flush();

        ;)*12Code

        D Offline
        D Offline
        Druuler
        wrote on last edited by
        #3

        Hi thanks for ur answer...but im using asynchronous beginreadline and need to keep cmd alive?

        1 1 Reply Last reply
        0
        • D Druuler

          Hi thanks for ur answer...but im using asynchronous beginreadline and need to keep cmd alive?

          1 Offline
          1 Offline
          12Code
          wrote on last edited by
          #4

          You only need to close StandardInput, not cmd.

          ;)*12Code

          D 1 Reply Last reply
          0
          • 1 12Code

            You only need to close StandardInput, not cmd.

            ;)*12Code

            D Offline
            D Offline
            Druuler
            wrote on last edited by
            #5

            hmm...But cmd exits when i close the input stream and even if it didnt exit how would i go about write to the input stream again? Could you give an code example maybe?

            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