Problem with executing external exe from vb.net

Joined
May 20, 2008
Messages
2
Reaction score
0
Hello Experts,

I am executing external exe from vb.net, but i m not getting output value which exe return after executing.

when i run that exe through command prompt it works fine and return the out as expected.

can u tell me where i m doing wrong. below is my code:


Public Function ExternalExecute() As String
Dim sMessage As String
Try
Dim Process As Process = New Process()
Dim s As String
Dim output As String
Dim outfile As String = "c:\Execute" & "\Output.txt"

Dim sysFolder As String = "c:\Execute"

Dim sArguments As String = "/C cd\" & sysFolder & " && ValidUser.exe address.txt >> " & Chr(34) & outfile & Chr(34) & " && exit"


Process.StartInfo.FileName = "cmd.exe"
Process.StartInfo.Arguments = sArguments
Process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
Process.StartInfo.CreateNoWindow = True
Process.StartInfo.RedirectStandardInput = True
Process.StartInfo.RedirectStandardOutput = True
Process.StartInfo.RedirectStandardError = True
Process.StartInfo.UseShellExecute = False

myProcess.Start()

output = myProcess.StandardOutput.ReadToEnd()
myProcess.WaitForExit(1000)

If Not myProcess.HasExited Then
myProcess.Kill()
End If


myProcess.Close()

Catch ex As Exception

sMessage = "Exception: " & ex.ToString() & " Message: " & ex.Message & " Source: " & ex.StackTrace & " : " & ex.StackTrace

End Try

End Function


Thanks & regards
john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top