Dos Front End (Multi Dos Windows)

Kayot

Well-known member
Joined
Mar 6, 2007
Messages
49
Programming Experience
3-5
Dos Front End

I want to make a Dos front end that will contain many dos windows. The questions are, how do I get a dos window to load in VB?

I'd like to also get the program to watch for key words. In a sense, I want to replace a ton of windows with one sweet VB front end.

I don't know how to start the project and I can't search the forum for the word dos as it's three letters. Do I need a library or can VB do dos on its own? I just need a starting path, I can do all the rest once I get an output.
 
For example use a Textbox to enter commands which you start with Process class. The output from this process you can redirect and write to an output Textbox, this also enables you to "watch" and handle the returned text. The Process.StandardOuput property in documentation have an code example of usage. Note that to issue shell commands (the commands that lists when you type 'help' in prompt) you have to route them through the Cmd.exe process with a /c or /k parameter. If you want the textbox to look like a 'dos' window you set backcolor black, forecolor white and use a fixed font like Courier New.
 
What if the dos process is a sustained process, like an emulator that runs continueisly but you want to use a front end to run it rather than a dos box. One reason I want to do this is because the emulator in question has a ton of windows and I want to make One GUI that encapsulates them all. And of course has features.
 
Do as in post 5 here, it will read line by line as long as the process sustains. You'd have to run the read asynchronously as its own thread to avoid the UI block while process is reading.
 
Ok, heres my code. I removed the loop because it would cause a system hang due to the fact that the dos window doesn't close. Any ideas?

VB.NET:
Private Sub GetProcessText(ByVal process As String, ByVal param As String, ByVal workingDir As String)       
	Dim proc As Process

	Dim info As New ProcessStartInfo("world")
	info.RedirectStandardOutput = True
	info.RedirectStandardInput = False
	info.UseShellExecute = False
	info.CreateNoWindow = True
	info.WorkingDirectory = Application.StartupPath
	proc = New Process()
	proc.StartInfo = info
	proc.Start()
	Dim line As String
	Dim StdOutput As System.IO.StreamReader = proc.StandardOutput

	'Do While proc.HasExited = False
	line = StdOutput.ReadLine
	If line <> "" Then
		Me.TextBox1.AppendText(line & vbNewLine)
	End If
End Sub

I was going to use a timer, but I figured that would be bad when a lot of text goes flying accost the screen. Any idea's that would display the results as they happened. Something like a HasChanged process?
 
I'm probably missing something simple, how do I combined these two code blocks to make a thread.

VB.NET:
Private Delegate Sub dlgUpdateUI(ByVal text As String)
 
Sub updateUI(ByVal text As String)
    If theControl.InvokeRequired = True Then
        Dim d As New dlgUpdateUI(AddressOf updateUI)
        theControl.Invoke(d, text)
    Else
        theControl.Items.Add(text)
    End If
End Sub

VB.NET:
Dim proc As Process
Dim info As New ProcessStartInfo("world")
Dim line As String
Dim StdOutput As System.IO.StreamReader

Private Sub GetProcessText()
	info.RedirectStandardOutput = True
	info.RedirectStandardInput = False
	info.UseShellExecute = False
	info.CreateNoWindow = True
	info.WorkingDirectory = Application.StartupPath
	proc = New Process()
	proc.StartInfo = info
	proc.Start()
	StdOutput = proc.StandardOutput

	Do While proc.HasExited = False
		line = StdOutput.ReadLine
		If line <> "" Then
			Me.TextBox1.AppendText(line & vbNewLine)
		End If
	Loop
End Sub

I'm not sure how to make a thread with the GetProcessText sub.
 
dim t as new thread(addressof GetProcessText)
t.start()

then you use the updateUI method from within GetProcessText (that now is different thread than main UI thread) to update TextBox1 safely.
 
Back
Top