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. Process in C#.. [modified]

Process in C#.. [modified]

Scheduled Pinned Locked Moved C#
csharpquestion
6 Posts 3 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.
  • S Offline
    S Offline
    Sr Frank
    wrote on last edited by
    #1

    Hi, I am creating a Process in C# and want to print my "strName" value to command prompt. This code is not printing any value , please let me know the right code. I know this code is wrong,,but if we pass Arguents then? string strName = "Alex"; Process pr = new Process(); pr.StartInfo.FileName = "cmd.exe"; pr.Start(); Thanks

    modified on Friday, April 9, 2010 10:14 AM

    I P 2 Replies Last reply
    0
    • S Sr Frank

      Hi, I am creating a Process in C# and want to print my "strName" value to command prompt. This code is not printing any value , please let me know the right code. I know this code is wrong,,but if we pass Arguents then? string strName = "Alex"; Process pr = new Process(); pr.StartInfo.FileName = "cmd.exe"; pr.Start(); Thanks

      modified on Friday, April 9, 2010 10:14 AM

      I Offline
      I Offline
      Ian Shlasko
      wrote on last edited by
      #2

      Have you tried going into the project properties and building it as a Console Application? Then just do: Console.WriteLine(strName);

      Proud to have finally moved to the A-Ark. Which one are you in?
      Author of the Guardians Saga (Sci-Fi/Fantasy novels)

      S 1 Reply Last reply
      0
      • I Ian Shlasko

        Have you tried going into the project properties and building it as a Console Application? Then just do: Console.WriteLine(strName);

        Proud to have finally moved to the A-Ark. Which one are you in?
        Author of the Guardians Saga (Sci-Fi/Fantasy novels)

        S Offline
        S Offline
        Sr Frank
        wrote on last edited by
        #3

        I am trying to do with process.

        S 1 Reply Last reply
        0
        • S Sr Frank

          I am trying to do with process.

          S Offline
          S Offline
          Sr Frank
          wrote on last edited by
          #4

          Using this code , and where to add new line of code which prints value to commandprompt. string strName = "Alex"; Process pr = new Process(); pr.StartInfo.FileName = "cmd.exe"; pr.Start();

          I 1 Reply Last reply
          0
          • S Sr Frank

            Using this code , and where to add new line of code which prints value to commandprompt. string strName = "Alex"; Process pr = new Process(); pr.StartInfo.FileName = "cmd.exe"; pr.Start();

            I Offline
            I Offline
            Ian Shlasko
            wrote on last edited by
            #5

            Ok, if you want to actually send commands to the prompt, as opposed to just outputting text, you can do that via standard input...

            pr.StartInfo.FileName = "cmd.exe";
            pr.StartInfo.UseShellExecute = false;
            pr.StartInfo.RedirectStandardInput = true;
            pr.Start();
            pr.StartInput.WriteLine(strName);

            Of course, "Alex" isn't a command, so this is just going to give an error. If you're trying to do something else, you're going to have to be a little more clear, because your question is rather vague.

            Proud to have finally moved to the A-Ark. Which one are you in?
            Author of the Guardians Saga (Sci-Fi/Fantasy novels)

            1 Reply Last reply
            0
            • S Sr Frank

              Hi, I am creating a Process in C# and want to print my "strName" value to command prompt. This code is not printing any value , please let me know the right code. I know this code is wrong,,but if we pass Arguents then? string strName = "Alex"; Process pr = new Process(); pr.StartInfo.FileName = "cmd.exe"; pr.Start(); Thanks

              modified on Friday, April 9, 2010 10:14 AM

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Aha! Unless this is a homework assignment, take a look at my ProcessCommunicator[^].

              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