468,241 Members | 1,555 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,241 developers. It's quick & easy.

knowing when a Process finsihed the Start

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


Nov 20 '05 #1
7 1054
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
Nov 20 '05 #2
* "Cor Ligthert" <no**********@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/>
Nov 20 '05 #3
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" <no**********@planet.nl> wrote in message
news:Os*************@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

Nov 20 '05 #4
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
Nov 20 '05 #5
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" <no**********@planet.nl> wrote in message
news:%2****************@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

Nov 20 '05 #6
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" <pi**********@hotmail.com> wrote in message
news:eM**************@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

Nov 20 '05 #7
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
Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Niklas Ringdahl | last post: by
44 posts views Thread by Smokey Grindle | last post: by
7 posts views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.