DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Running dos command in VB

  1. #1
    Join Date
    Jan 2007
    Posts
    1

    Running dos command in VB

    Hi

    I am very new to VB .net 2003 and want to know how should I run dos commands with arguments in VB and redirect its output to a file.
    Also, would like to know if there is a way to parse the output given by the dos command bcoz I need to use the result obtained by the dos command in later.

    Please help.

    Thanks in advance

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Code:
    Dim psi As New System.Diagnostics.ProcessStartInfo("d:\path\filename.exe", "arg1 arg2")
    With psi
        .UseShellExecute = False
        .ErrorDialog = False
        .CreateNoWindow = True
        .RedirectStandardOutput = True
    End With
    Dim p As Process = System.Diagnostics.Process.Start(psi)
    Dim sr As System.IO.StreamReader = p.StandardOutput
    Dim output As String = sr.ReadToEnd()
    sr.Close()
    The spawned app's output is now in the variable named "output."
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Running a Batch File From VB Application
    By wandera in forum VB Classic
    Replies: 1
    Last Post: 09-16-2005, 05:56 AM
  2. Running VB Scripts using SQL Server 7 triggers
    By Nitin Sanghi in forum Database
    Replies: 2
    Last Post: 01-22-2001, 12:20 PM
  3. Running Sql Script(.sql file) through VB
    By Sumit in forum Database
    Replies: 1
    Last Post: 12-04-2000, 09:41 AM
  4. Running a VB app as a Windows Control Panel applet
    By John Nelson in forum VB Classic
    Replies: 0
    Last Post: 11-14-2000, 10:12 AM
  5. running VB exe(s)
    By jj in forum VB Classic
    Replies: 2
    Last Post: 10-26-2000, 01:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center