472,952 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

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 1229
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ana | last post by:
Hi! I have problems with the following scenario: My application is developed using C# under .NET. It must run on all Windows versions starting from Windows 98. The user must open different...
0
by: Abhi | last post by:
Hi- I'm trying to execute the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\50\bin\OWSADM.EXE programmatically from a shell using the process.Start() method. I'm also...
2
by: Niklas Ringdahl | last post by:
Hello. I am using databindings to bind my dataset to comboboxes, textboxes and labels. Some of my UI depends on knowing when the user changes the values, but I have some problems knowing when my...
4
by: Charles Law | last post by:
Is there a way to dynamically remove an event handler from an event without knowing the name of the handler? For example, how can ClassB remove the handler without knowing the name, or how many...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
0
by: Buddy Home | last post by:
There is two examples of code. Example 1. Send and Receive within the same process. Put this code in a console app called SendAndReceive and run the code. using System; using...
44
by: Smokey Grindle | last post by:
I have a list box on my form, but I need to databind it to a data table that is a private member of the form's class... so I basically have Public Class MyForm priate m_MyTable as new datatable...
7
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, misters, I have Windows App .net 2.0 + vs 2005. My form launch several MSI's (app1.msi, app2.msi). I try launch MSI using Process.Start. I need know when detect MSI executable has...
3
by: Saser | last post by:
Hi all bytes out there. I have a few little problems in my program. The program is supposed to help me to not spend too much time of my day at the computer ;) I play a game called...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.