Spawning Another Process??

  • Thread starter Thread starter Remulac
  • Start date Start date
R

Remulac

I'm trying to execute a DOS program from within VB.NET. Of course, I
used to simply use Shell(), but that doesn't seem to work even when I
import the VisualBasic namespace. Here's the code I'm using now:

Debug.WriteLine("in here")
System.Diagnostics.Process.Start("c:\NetCdf\ncdump.exe", " Test.nc >>
fromprog.txt")
Debug.WriteLine("in there")


Both diagnostic lines print out, and there is no error message, yet
the call to Process.Start seems to do nothing. If I go to the \NetCdf
directory and type:

ncdump test.nc >> fromprog.txt

I get the results I want, which is the info from test.nc dumped into
an ASCII text file. Does anyone have any idea why this won't work?

Thanks in advance for your help.
 
* (e-mail address removed) (Remulac) scripsit:
I'm trying to execute a DOS program from within VB.NET. Of course, I
used to simply use Shell(), but that doesn't seem to work even when I
import the VisualBasic namespace. Here's the code I'm using now:

Debug.WriteLine("in here")
System.Diagnostics.Process.Start("c:\NetCdf\ncdump.exe", " Test.nc >>
fromprog.txt")
Debug.WriteLine("in there")


Both diagnostic lines print out, and there is no error message, yet
the call to Process.Start seems to do nothing. If I go to the \NetCdf
directory and type:

ncdump test.nc >> fromprog.txt

I get the results I want, which is the info from test.nc dumped into
an ASCII text file. Does anyone have any idea why this won't work?

Start "cmd.exe" and pass the command to the command line:

<URL:http://dotnet.mvps.org/dotnet/samples/miscsamples/downloads/RedirectConsole.zip>
 
Debug.WriteLine("in here")
System.Diagnostics.Process.Start("c:\NetCdf\ncdump.exe", " Test.nc >>
fromprog.txt")
Debug.WriteLine("in there")


Both diagnostic lines print out, and there is no error message, yet
the call to Process.Start seems to do nothing. If I go to the \NetCdf
directory and type:

ncdump test.nc >> fromprog.txt

In addition to Herfrieds comments, have a look at the ProcessStartInfo
class, specifically the RedirectStandardOutput property.

Redirecting the output using the >> as you are trying to do is only
understood by the cmd.exe, not the ncdump.exe app.
 
Back
Top