2022-08-22 12:33 PM
Running in vb.net I can successfully load code to a target using a .bat file using:
System.Diagnostics.Process.Start("c:\rp:\boot.bat")
In the above case a command window is shown during the load with session information. It goes away when complete.
However, if I launch the bat file as a "process" and look for the STD output, I get nothing. However the "process" loads a file correctly.
' define a process
Dim p As New Process
p.StartInfo.FileName = "boot.bat"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.CreateNoWindow = True
p.EnableRaisingEvents = True
Application.DoEvents()
' add a handler so we can easily display the data
AddHandler p.OutputDataReceived, AddressOf Showme
p.Start()
p.BeginOutputReadLine()
Application.DoEvents()
' spin here till done or cancel
Do While (p.HasExited = False) And (CANCEL = False)
' monitor progress
Application.DoEvents()
Loop
I never get an event on OutputDataReceived. Does the cli version issue standard output? If not, is there a good workaround?
Thanks!
2022-08-22 12:47 PM
Are you sure it's coming out of STDOUT (1) and not STDERR (2) ?
Piping the latter
foo 2>err.log
2022-08-22 01:14 PM
First...thank you for your response...
Two findings:
1) If I add:
p.StartupInfo.Arguments = "> " & Echofile
The file is correctly populated with the load session info.
2) If I add:
p.StartupInfo.RedirectStandardError = True
p. ErrorDataReceived, Addressof Showmeerror
I still never get a "hit" on the above event.
Any additional ideas?
Thanks