I need to execute commandpromt process async and get the output of the execution. i currently have this code
Public Function ExecuteCommandSync(ByVal command As Object) As String
Dim result As String = Nothing
Try
Dim procStartInfo As New System.Diagnostics.ProcessStartInfo("cmd", "/c " & Convert.ToString(command))
procStartInfo.RedirectStandardOutput = True
procStartInfo.UseShellExecute = False
procStartInfo.CreateNoWindow = True
Dim proc As New System.Diagnostics.Process()
proc.StartInfo = procStartInfo
proc.Start()
result = proc.StandardOutput.ReadToEnd()
Console.WriteLine(result)
Catch objException As Exception
End Try
Return result
End Function
Please help me on converting this to async without using a thread. it this possible?
thanks
Below is a class that achieves I believe what you are looking for.
The process is already running async, I believe what you are looking for is event driven and hidden. Do you specifically want a blocking call for some reason, or scared of the threading?
If I am off base and you want it to block, let me know we can do that too, I cannot imagine why though.
It essentially allows you to create a cmd shell and interact with it invisibly.