Hi,

I want my application to Start another application. I do it like this:
Dim prcSiclid As New Process
prcSiclid.StartInfo.UseShellExecute = True
prcSiclid.StartInfo.RedirectStandardOutput = False
prcSiclid.StartInfo.WorkingDirectory = strDeskTop
prcSiclid.StartInfo.FileName = strDeskTop & "\TBEN.lnk"
prcSiclid.Start()

After starting the new application (TBEN) I have to start a scritp that does
the login in that application. The problem is: starting tha application
takes some time (2-3 seconds), so I need to wait untill the application has
fully started. So what I basically need is soem kind of event that tells me
that the application finished the Start, or a way to see this (I can
eventually work with a timer to see if it has alreaddy finished).

Does anybody knows how to do this? Any help would really be appreciated!

Thanks a lot in advance,

Pieter

Re: knowing when a Process finsihed the Start by Cor

Cor
Tue Apr 27 05:41:35 CDT 2004

Hi Pieter,

Does that application throw something on the commandline, maybe you can than
use the redirectStandardOutput.

(Is very simple to get)

Dim sr As IO.StreamReader = p.StandardOutput
Dim sb As New System.Text.StringBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW(input))
input = sr.Read
Loop

And then in that loop something as
if sb.tostring = "blabla"
exit do
end if

Cor



Re: knowing when a Process finsihed the Start by hirf-spam-me-here

hirf-spam-me-here
Tue Apr 27 06:07:50 CDT 2004

* "Cor Ligthert" <notfirstname@planet.nl> scripsit:
> Does that application throw something on the commandline, maybe you can than
> use the redirectStandardOutput.

Maybe it throws "Starting, please wait..." onto the standard output :-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Re: knowing when a Process finsihed the Start by DraguVaso

DraguVaso
Tue Apr 27 07:11:39 CDT 2004

It doesn't work :-(
If I want to use that I need to set prcSiclid.StartInfo.UseShellExecute =
False and prcSiclid.StartInfo.RedirectStandardOutput = True. But than my
application throws an exception when it wants to start the process:

"An unhandled exception of type 'System.ComponentModel.Win32Exception'
occurred in system.dll
Additional information: %1 is not a valid Win32 application"

The code I use is this:
prcSiclid = New Process
prcSiclid.StartInfo.UseShellExecute = False
prcSiclid.StartInfo.RedirectStandardOutput = True
prcSiclid.StartInfo.WorkingDirectory = strDeskTop
strDeskTop = "C:\Documents and Settings\COUCKE\My
Documents\Attachmate\Sessions"
prcSiclid.StartInfo.FileName = strDeskTop & "\TBEN.edp"
'prcSiclid.EnableRaisingEvents = True
prcSiclid.Start()

Dim sr As IO.StreamReader = prcSiclid.StandardOutput
Dim sb As New System.Text.StringBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW(input))
input = sr.Read
Loop
MsgBox(sb.ToString)

Anybody knows a solution?


"Cor Ligthert" <notfirstname@planet.nl> wrote in message
news:Os$S8QELEHA.912@tk2msftngp13.phx.gbl...
> Hi Pieter,
>
> Does that application throw something on the commandline, maybe you can
than
> use the redirectStandardOutput.
>
> (Is very simple to get)
>
> Dim sr As IO.StreamReader = p.StandardOutput
> Dim sb As New System.Text.StringBuilder("")
> Dim input As Integer = sr.Read
> Do Until input = -1
> sb.Append(ChrW(input))
> input = sr.Read
> Loop
>
> And then in that loop something as
> if sb.tostring = "blabla"
> exit do
> end if
>
> Cor
>
>



Re: knowing when a Process finsihed the Start by Cor

Cor
Tue Apr 27 07:40:14 CDT 2004

Hi Pieter,

Or I oversee something, but I thought I have a piece of running program
what I can almost lay upon it. I gues the strDesktop is wrong

Cor



Re: knowing when a Process finsihed the Start by DraguVaso

DraguVaso
Tue Apr 27 07:47:09 CDT 2004

If I use this, it works fine, but I don't know when it is finished than...
prcSiclid = New Process

prcSiclid.StartInfo.UseShellExecute = True

prcSiclid.StartInfo.RedirectStandardOutput = False

prcSiclid.StartInfo.WorkingDirectory = strDeskTop

strDeskTop = "C:\Documents and Settings\COUCKE\My
Documents\Attachmate\Sessions"

prcSiclid.StartInfo.FileName = strDeskTop & "\TBEN.edp"

'prcSiclid.EnableRaisingEvents = True

prcSiclid.Start()


"Cor Ligthert" <notfirstname@planet.nl> wrote in message
news:%23AYnPTFLEHA.2704@TK2MSFTNGP10.phx.gbl...
> Hi Pieter,
>
> Or I oversee something, but I thought I have a piece of running program
> what I can almost lay upon it. I gues the strDesktop is wrong
>
> Cor
>
>



Re: knowing when a Process finsihed the Start by Stoitcho

Stoitcho
Tue Apr 27 08:08:41 CDT 2004

Hi DraguVaso,
If the application has an UI you can use Process.WaitForInputIdle. When this
method returns the process is started.


--
HTH
B\rgds
Stoitcho Goutsev (100) [C# MVP]

"DraguVaso" <pietercoucke@hotmail.com> wrote in message
news:eM9UCCELEHA.1272@tk2msftngp13.phx.gbl...
> Hi,
>
> I want my application to Start another application. I do it like this:
> Dim prcSiclid As New Process
> prcSiclid.StartInfo.UseShellExecute = True
> prcSiclid.StartInfo.RedirectStandardOutput = False
> prcSiclid.StartInfo.WorkingDirectory = strDeskTop
> prcSiclid.StartInfo.FileName = strDeskTop & "\TBEN.lnk"
> prcSiclid.Start()
>
> After starting the new application (TBEN) I have to start a scritp that
does
> the login in that application. The problem is: starting tha application
> takes some time (2-3 seconds), so I need to wait untill the application
has
> fully started. So what I basically need is soem kind of event that tells
me
> that the application finished the Start, or a way to see this (I can
> eventually work with a timer to see if it has alreaddy finished).
>
> Does anybody knows how to do this? Any help would really be appreciated!
>
> Thanks a lot in advance,
>
> Pieter
>
>
>
>



Re: knowing when a Process finsihed the Start by Cor

Cor
Tue Apr 27 08:52:15 CDT 2004

Hi Pieter,

I do not know if the solution from Stoitcho fits, that is absolute better I
think.

However my idea was to catch the first text on the commandline and than to
exit.

So it is looping reading and then something in the loop however it can even
be this.

Do Until input = asc("P") ' And that P is the first character that will be
displayed on console
exit do
Loop

Cor