By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,665 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,665 IT Pros & Developers. It's quick & easy.

knowing when a Process finsihed the Start

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
* "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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.