command line capture

Hi I'm using a bat file to compile java source.
I want to capture the results from that bat. but the strange thing is that the error debug printet from the compile is not returned!

vbnet code:
----------------------------------------------------
        Dim Proc As New Process,response as string
        Proc.StartInfo.FileName = "C:\Symbian\UIQ_21\erj\helloworld\compile.bat"
        Proc.StartInfo.Arguments = ""
        Proc.StartInfo.UseShellExecute = False
        Proc.StartInfo.RedirectStandardOutput = True
        Proc.StartInfo.CreateNoWindow = False
        Proc.Start()
        Proc.WaitForExit()
        response = Replace(Proc.StandardOutput.ReadToEnd(), vbFormFeed, "")
        response = Replace(response, vbLf, vbNewLine)

running the bat file in cmd line:
--------------------------------------------------------------------
source\HelloWorld.java:29: ';' expected
^
1 error
Failed to compile HelloWorld

but in the vb.net I get this :
---------------------------------------------------------------------
Failed to compile HelloWorld

compile.bat
-------------------------------------------------------------
@echo off
if "%epocroot%" == "" goto noepocroot
set appname=HelloWorld
set localclasspath=%epocroot%erj\ext\qawt.jar;%epocroot%erj\ext\util.jar;C:\Symbian\UIQ_21\erj\helloworld\generator\..\source;%epocroot%epoc32\java\ext\javaphone.jar;%epocroot%epoc32\java\lib\classes.zip;%epocroot%epoc32\tools\javalib

cd C:\Symbian\UIQ_21\erj\helloworld\generator\..\
if not exist C:\Symbian\UIQ_21\erj\helloworld\generator\..\code\ mkdir C:\Symbian\UIQ_21\erj\helloworld\generator\..\code
javac  -target 1.1 -classpath %localclasspath% -d code source\*.java

if errorlevel 1 goto failed
cd code
jar -cf ..\install\HelloWorld.jar *.class
cd ..
echo Successfully compiled HelloWorld
goto exit

:failed
echo Failed to compile HelloWorld
goto exit

:noepocroot
echo The environment variable 'epocroot' has not been set.
echo Ensure that it is set to where you installed the UIQ SDK.
echo E.g. C:\Symbian\UIQ_21\
goto exit

:exit
LVL 2
thor918Asked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
It's a long shot but I have always placed the call to ReadToEnd() BEFORE WaitForExit():

        response = Replace(Proc.StandardOutput.ReadToEnd(), vbFormFeed, "")
        Proc.WaitForExit()
        response = Replace(response, vbLf, vbNewLine)

See if that makes any difference.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You may have also to place the results of ReadToEnd() into a local temp string variable instead of directly into the Replace() command.
0
 
thor918Author Commented:
no it did not make any difference
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
thor918Author Commented:
not to confuse anyone with the bat to much I made one less complicated:
same result the debug info from javacompile is cut off:
compile.bat:
set appname=HelloWorld
set localclasspath=%epocroot%erj\ext\qawt.jar;%epocroot%erj\ext\util.jar;C:\Symbian\UIQ_21\erj\helloworld\generator\..\source;%epocroot%epoc32\java\ext\javaphone.jar;%epocroot%epoc32\java\lib\classes.zip;%epocroot%epoc32\tools\javalib

cd C:\Symbian\UIQ_21\erj\helloworld\generator\..\
javac  -target 1.1 -classpath %localclasspath% -d code source\*.java
0
 
thor918Author Commented:
ahhh.it was easy!
        Proc.StartInfo.RedirectStandardError = True
Proc.StandardError.ReadToEnd(),
and just read out the error stream. then I get the result I was looking for!
0
 
thor918Author Commented:
would be nice if anyone could show me to get the cmd runned totaly hidden.
as this code flashes the cmd line window
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.