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. Need help .....

Need help .....

Scheduled Pinned Locked Moved C#
csharphelp
6 Posts 5 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
    superselector
    wrote on last edited by
    #1

    I have following requirement to develop in C# Open command prompt i.e. invoke cmd.exe run cd/ command run command1 run coomand2 run command 3 run exit command I need to save the output of the command1 , command2 and command3 in the same text file. Please provide a sample code to execute multiple commands one by one and save output to same text file

    L L OriginalGriffO M 4 Replies Last reply
    0
    • S superselector

      I have following requirement to develop in C# Open command prompt i.e. invoke cmd.exe run cd/ command run command1 run coomand2 run command 3 run exit command I need to save the output of the command1 , command2 and command3 in the same text file. Please provide a sample code to execute multiple commands one by one and save output to same text file

      L Offline
      L Offline
      lukeer
      wrote on last edited by
      #2

      Errm, ..., no. But have a look at MSDN on the Process class[^]. It is used to start other processes. Pay special attention to its StandardOutput[^] and StandardError[^] properties. They give you access to the called processes' outputs. Finally, use File.WriteAllText()[^] to store the results in a file. Or forget it all and go for Eddy Vluggen's proposal.

      Ciao, luker

      1 Reply Last reply
      0
      • S superselector

        I have following requirement to develop in C# Open command prompt i.e. invoke cmd.exe run cd/ command run command1 run coomand2 run command 3 run exit command I need to save the output of the command1 , command2 and command3 in the same text file. Please provide a sample code to execute multiple commands one by one and save output to same text file

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        superselector wrote:

        I have following requirement to develop in C#

        Basically a batch-file whose output is redirected. A batch-file is a collection of commands that are executed one after another;

        DIR C:\TEST
        DIR C:\TEST2

        You could redirect the output when calling the batch-file, like "MYBATCH.BAT >C:\RESULT.TXT".

        superselector wrote:

        Open command prompt i.e. invoke cmd.exe

        Google for "C# redirect console output" for examples.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        1 Reply Last reply
        0
        • S superselector

          I have following requirement to develop in C# Open command prompt i.e. invoke cmd.exe run cd/ command run command1 run coomand2 run command 3 run exit command I need to save the output of the command1 , command2 and command3 in the same text file. Please provide a sample code to execute multiple commands one by one and save output to same text file

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          superselector wrote:

          Please provide a sample code to execute multiple commands one by one and save output to same text file

          No. That isn't how it works here. We don't do homework, and we don't do your work for you either. If you want code written for you to a specific specification, you have to pay - I suggest you go to VWorker.com and ask there. But be aware: you get what you pay for. Pay peanuts, get monkeys. If on the other hand you try to do it and get stuck, then feel free to ask for help with a specific problem and we will be glad to assist. But we aren't going to do it all for you.

          The only instant messaging I do involves my middle finger. English doesn't borrow from other languages. English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          S 1 Reply Last reply
          0
          • S superselector

            I have following requirement to develop in C# Open command prompt i.e. invoke cmd.exe run cd/ command run command1 run coomand2 run command 3 run exit command I need to save the output of the command1 , command2 and command3 in the same text file. Please provide a sample code to execute multiple commands one by one and save output to same text file

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            superselector wrote:

            Need help.....

            You certainly do!

            Never underestimate the power of human stupidity RAH

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              superselector wrote:

              Please provide a sample code to execute multiple commands one by one and save output to same text file

              No. That isn't how it works here. We don't do homework, and we don't do your work for you either. If you want code written for you to a specific specification, you have to pay - I suggest you go to VWorker.com and ask there. But be aware: you get what you pay for. Pay peanuts, get monkeys. If on the other hand you try to do it and get stuck, then feel free to ask for help with a specific problem and we will be glad to assist. But we aren't going to do it all for you.

              The only instant messaging I do involves my middle finger. English doesn't borrow from other languages. English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.

              S Offline
              S Offline
              superselector
              wrote on last edited by
              #6

              Hi i have implemented the same in vbscript . i was aware of the batch file concept but wanted to configure the commands in the code itself using Process class in C#.as i don't want it in batch .. thanks for your suggestion though.

              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