sorry guys,
I'd had bottle of wine and it was after a hard days work. Having just re-read it i see what you mean.
Since it's now 11.15 in the morning let see if i can more sense!!
this is my first real vb.net app that I've written. It takes over from a batch file menu that calls other batch files to do certain tasks. (such as copying files to remote Pc's, fixing the missing toolbar in excel, restarting services and Pc's and most recently helping with an install that we're doing at over 300 sites with around 5 Pc's each. - .ini files get made with correct details for site and files get transfered.
At first i had just used shell to call the batch file that did the work. I then decided it would look much nicer if the output from the batch file was brought back in to vb in a status window (listbox)
The problem i had was i that really wanted the lines to appear in the status (listbox) window as they where run in the batch file. This was proving to be a pain, so i decided that i had might as well just write in vb.net the commands that the batch file was running, that way i could get it to display as it ran.
the issue i now have is that my form doesn't display each command as it is run, it still waits for the whole form to finish.
heres the function called dos;
Code:
Imports System.io
Module dos
Public Sub dos1(ByVal fileName As String, ByVal arguments As String)
Dim p As New Process()
With p
.StartInfo.Arguments = arguments
.StartInfo.CreateNoWindow = True
.StartInfo.FileName = fileName
.StartInfo.RedirectStandardOutput = True
.StartInfo.UseShellExecute = False
.Start()
Dim reader As StreamReader = .StandardOutput
While (Not reader.EndOfStream)
Formstatus.statuslist.Items.Add(String.Format("{0}", reader.ReadLine))
Formstatus.statuslist.HorizontalScrollbar = True
Formstatus.Show()
End While
.WaitForExit()
End With
p.Close()
End Sub
and heres the form where the "testmerun" button is clicked;
Code:
Public Class Formtestme
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testmerun.Click
dos.dos1("cmd", "/c copy c:\" + Test.Text + ".txt c:\temp\nice2.txt")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testmerun.Click
System.Threading.Thread.Sleep(15 * 1000)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testmerun.Click
dos.dos1a("cmd", "/c copy c:\" + Test.Text + ".txt c:\temp\nice3.txt")
End Sub
End Class
i reckon its something simple. (just beyond me!!)
i know that i could just use some fso to copy files, but I've started down this route so I'd like to finish it. (also, helps with the learning process to complete each project.)
hope that makes more sense!!
blastman