help with vb.net

due to the nature of the commands that the batch file runs, (and my experience with vb.net) it'll be better to just get vb to run them and then pull the output back in.

I've managed to get it working but with one side-effect. It now appears that my listbox is only displaying the first line of the batch file.

For example, if i get the batch file to run dir on the root of my PC all i get displayed is "volume c:\ has no label"

I have;

Code:
dim i as integer
for i = 0 to 15
the display to listbox code here
next i

but this just multiplies the "volume c:\ has no label" 15 times on different lines.

any idea how i can get it display the rest of the dir command??

cheers again for the help.
 
Why are you using a For Loop? You are reading the output from a stream. Use While (Not Stream.EndOfStream) etc....

TrUz
 
so,

use while instead of for....

Ok. I've tried but tbh my knowledge is very limited.

I've googled but i'm not seeming to get anywhere.

Could you post just a small bit of code explaining how it would benefit me???

big ask i know. :-)

cheers dude
 
If you do something similar to this:
Code:
While (Not std_out.EndOfStream)
    'Do something
End While
TrUz
 
cheers,

so in that 'do somthing, i'd need to keep the loop going untill std_out has finished.

right?

that way it would keep reading untill the whole thing was finished and then display??

cheers again
 
In the 'Do something you would probably op for some thing like:
Code:
textBox1.text = std_out.ReadLine() & vBCrLf
TrUz
 
hey cool,

I think i've got it,:p
Code:
While (Not std_out.EndOfStream)
            Formstatus.statuslist.HorizontalScrollbar = True
            Formstatus.statuslist.Items.Add(std_out.ReadLine)
            Formstatus.Show()
        End While
displays,

status-1.jpg





this works in the sense that i get all of the information writen inside the batch file, inculding the commands and thier results.

can this be filtered out so only the results ("commands completed") show up without outputting to a txt file and then back in again??

thanking you!!!:D
 
Last edited:
Yeah, you could do something like this:
Code:
While (Not std_out.EndOfStream)
    Dim temp As String = std_out.ReadLine()
            
    Formstatus.statuslist.HorizontalScrollbar = True

    If(temp = "Command Complete") Then
        Formstatus.statuslist.Items.Add(temp)
    End If

    Formstatus.Show()
End While
TrUz
 
cheers for replying,

I have done as suggested but in stead of "command completed" I've replaced it with "1 files(s) copied." as this is what this batch file does. (just using as a test to get this form working before applying to others)

This doesn't throw any errors once run but doesn't display anything in the status box.

I have also attached the std_err that i have to a messagebox but that isn't showing any errors either.

Is this process just picking up the last line of the batch file or should it display the "1 file(s) copied." if it's present in the batch file output?

cheers again for the help and your patience dude!
 
Last edited:
not to worry,

I've decided to write the dos commands in to vb, and get each line as it runs to display, giving me the "live" output i require.

because i have an idea but need help I'll start a new thread!!!

cheers for all your help!

blastman
 
Back
Top Bottom