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. Visual Basic
  4. Capture output

Capture output

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
5 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.
  • T Offline
    T Offline
    Teir
    wrote on last edited by
    #1

    I launch a dos program inside my program and then capture the command line output to my VB program. How to do this? Thanks!

    R 1 Reply Last reply
    0
    • T Teir

      I launch a dos program inside my program and then capture the command line output to my VB program. How to do this? Thanks!

      R Offline
      R Offline
      Ray Cassick
      wrote on last edited by
      #2

      When you shell out to your DOS application, pipe the output to a file using the '>' directive, then reed the file in after the program is done.


      Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
      George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things."


      T 1 Reply Last reply
      0
      • R Ray Cassick

        When you shell out to your DOS application, pipe the output to a file using the '>' directive, then reed the file in after the program is done.


        Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
        George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things."


        T Offline
        T Offline
        Tatham
        wrote on last edited by
        #3

        This is a very inefficient way to do this and will only return the complete result after the program has finished executing. :~ Providing you've left the caves and moved into .NET, the more efficient way is to: Dim myProc As New System.Diagnostics.Process myProc.StartInfo.UseShellExecute = False myProc.StartInfo.RedirectStandardOutput = True myProc.StartInfo.FileName = "ping" myProc.StartInfo.Arguments = "www.google.com" myProc.Start() You have now taken control of the process and have access to the output AND input streams. You could even write your own version of command.com if you wanted. :) The output stream is located at: myProc.StandardOutput Im sure you'll find the rest. Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript) tatham@e-oddie.com +61 414 275 989

        R 1 Reply Last reply
        0
        • T Tatham

          This is a very inefficient way to do this and will only return the complete result after the program has finished executing. :~ Providing you've left the caves and moved into .NET, the more efficient way is to: Dim myProc As New System.Diagnostics.Process myProc.StartInfo.UseShellExecute = False myProc.StartInfo.RedirectStandardOutput = True myProc.StartInfo.FileName = "ping" myProc.StartInfo.Arguments = "www.google.com" myProc.Start() You have now taken control of the process and have access to the output AND input streams. You could even write your own version of command.com if you wanted. :) The output stream is located at: myProc.StandardOutput Im sure you'll find the rest. Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript) tatham@e-oddie.com +61 414 275 989

          R Offline
          R Offline
          Ray Cassick
          wrote on last edited by
          #4

          Well that seems very elegant. I have to admit that I was unaware of how to do that. It does only work for VB.NET however. I am not sure what Teir was working in (.NET or VB6). Thanks.


          Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
          George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things."


          T 1 Reply Last reply
          0
          • R Ray Cassick

            Well that seems very elegant. I have to admit that I was unaware of how to do that. It does only work for VB.NET however. I am not sure what Teir was working in (.NET or VB6). Thanks.


            Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
            George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things."


            T Offline
            T Offline
            Tatham
            wrote on last edited by
            #5

            I have implemented this code in a WebForm which basically gives me a remote command line into the server. I never thought I would tunnel DOS over the internet. This does make a few holes in the security of shared hosting as it effectively bypasses all permissions. While you may not by able to use System.IO to delete say C:\Autoexec.bat - you can upload a console app and execute that from the machines system account. Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript) tatham@e-oddie.com +61 414 275 989

            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