Getting DOS output
-
Hi, I am using the following to redirect the output of a dos command to a richtextbox but anytime I try run it to get the directory listing of a large CD nothing happens but if there is only one file on the CD it works. Can anyone help. Dim myProcess As Process = New Process Dim prgOutput As String ' Output from DOS program myProcess.StartInfo.FileName = "c:\dir.bat" 'Full pathname to including file name myProcess.StartInfo.CreateNoWindow = True ' Does not create a window DOS program myProcess.StartInfo.UseShellExecute = False ' Must be false to redirect output myProcess.StartInfo.RedirectStandardOutput = True myProcess.Start() ' Start the DOS program myProcess.WaitForExit() ' Wait until it completes before moving on prgOutput = myProcess.StandardOutput.ReadToEnd ' Get the DOS output rtbOutput.Text = prgOutput I am using a .bat file which has the following commands: @ECHO OFF d: dir /A /S /O:GNE c: Running the .bat file directly from the command prompt works on the disc with loads of files Thanks
-
Hi, I am using the following to redirect the output of a dos command to a richtextbox but anytime I try run it to get the directory listing of a large CD nothing happens but if there is only one file on the CD it works. Can anyone help. Dim myProcess As Process = New Process Dim prgOutput As String ' Output from DOS program myProcess.StartInfo.FileName = "c:\dir.bat" 'Full pathname to including file name myProcess.StartInfo.CreateNoWindow = True ' Does not create a window DOS program myProcess.StartInfo.UseShellExecute = False ' Must be false to redirect output myProcess.StartInfo.RedirectStandardOutput = True myProcess.Start() ' Start the DOS program myProcess.WaitForExit() ' Wait until it completes before moving on prgOutput = myProcess.StandardOutput.ReadToEnd ' Get the DOS output rtbOutput.Text = prgOutput I am using a .bat file which has the following commands: @ECHO OFF d: dir /A /S /O:GNE c: Running the .bat file directly from the command prompt works on the disc with loads of files Thanks
-
Hi, I am using the following to redirect the output of a dos command to a richtextbox but anytime I try run it to get the directory listing of a large CD nothing happens but if there is only one file on the CD it works. Can anyone help. Dim myProcess As Process = New Process Dim prgOutput As String ' Output from DOS program myProcess.StartInfo.FileName = "c:\dir.bat" 'Full pathname to including file name myProcess.StartInfo.CreateNoWindow = True ' Does not create a window DOS program myProcess.StartInfo.UseShellExecute = False ' Must be false to redirect output myProcess.StartInfo.RedirectStandardOutput = True myProcess.Start() ' Start the DOS program myProcess.WaitForExit() ' Wait until it completes before moving on prgOutput = myProcess.StandardOutput.ReadToEnd ' Get the DOS output rtbOutput.Text = prgOutput I am using a .bat file which has the following commands: @ECHO OFF d: dir /A /S /O:GNE c: Running the .bat file directly from the command prompt works on the disc with loads of files Thanks
johnjsm wrote:
myProcess.WaitForExit() ' Wait until it completes before moving on prgOutput = myProcess.StandardOutput.ReadToEnd ' Get the DOS output
Try changing the order of these two lines
Cheers, Suresh
-
johnjsm wrote:
myProcess.WaitForExit() ' Wait until it completes before moving on prgOutput = myProcess.StandardOutput.ReadToEnd ' Get the DOS output
Try changing the order of these two lines
Cheers, Suresh