Home All Groups Group Topic Archive Search About

Strange console behavior

Author
5 Apr 2006 11:20 AM
Tobias Weltner [MVP]
I just tried to create a redirected console. Works BUT when I launch
external apps with GUI (not console apps), they remain invisible and prevent
my app from closing (it stays in the task manager list). When I kill it, all
launched invible apps turn visible.

Anyone a clue????

Here's the .NET 2.0 code:

ublic Class Form1

WithEvents p As Process

Private Declare Function AllocConsole Lib "kernel32" () As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

InitHost()

End Sub

Sub InitHost()

AllocConsole()

Dim psi As ProcessStartInfo = New ProcessStartInfo

psi.FileName = "cmd.exe"

psi.UseShellExecute = False

psi.RedirectStandardInput = True

psi.RedirectStandardOutput = True


p = Process.Start(psi)

p.StandardInput.WriteLine("notepad.exe")

p.StandardInput.WriteLine("notepad.exe")

p.StandardInput.WriteLine("notepad.exe")

p.StandardOutput.ReadToEnd()

p.WaitForExit()

End Sub

End Class

AddThis Social Bookmark Button