I have an exe that works in command prompt and needs two parameters feeded and enter pushed (to get some calculation results). However I need this to be worked directly from my vb.net application, so that those two parameters are feeded automatically and the results read into vb.
I can make the external exe run with Shell-command and i can feed commands to cmd with SendKeys class so that the external exe makes its calculation properly. But the calculation results appear in the cmd prompt window and I can't make my software read them. Is there any simple solution to this?
Loading
JuhaPosted Oct 28, 2011, 6:32 AM
Dim proc As New Process()
Dim result As String = ""
Dim argString as String = "Whatever"
Dim feed1 as String = "1st feed value"
Dim feed2 as String = "2nd feed value"
proc.StartInfo.FileName = "myexe.exe"
proc.StartInfo.Arguments = argString
proc.StartInfo.CreateNoWindow = True
proc.StartInfo.RedirectStandardInput = True
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.UseShellExecute = False
proc.Start()
proc.StandardInput.WriteLine(feed1 & " " & feed2)
proc.StandardInput.Close()
result = proc.StandardOutput.ReadToEnd
I just replaced arguments and those feeded values with proper values. Works perfectly. :)
VulpesPosted Oct 28, 2011, 4:30 AM