467,081 Members | 1,251 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

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

Process.Start() and Process.WaitForExit()

Hello,

I have a Windows Forms application which has buttons to click to run
other programs.

One of the applications it must run is a ClickOnce Windows Forms
application, so the Application Reference in the start menu is the only
way to access it.

I have the following code used to start the other program:

System.Diagnostics.Process _proc;
string ExecutableName;

ExecutableName = "C:\\Documents and
Settings\\User\\Start Menu\\Programs\\App1\\App1.appref-ms";
_proc = new System.Diagnostics.Process();
_proc.StartInfo.FileName = ExecutableName;
_proc.StartInfo.UseShellExecute = true;
_proc.StartInfo.WindowStyle =
ProcessWindowStyle.Normal;
_proc.Start();

It DOES successfully start the application. The original Forms
Application must WAIT on the other program, so I added the following
line:

_proc.WaitForExit();

When it executes that line, I get an Exception "No process is
associated with this object".

If I execute an old VB6 application instead of the ClickOnce
application, _proc contains valid information and the WaitForExit works
fine. What is the problem here?

One thing I have noticed is that the ClickOnce application only shows
up in Task Manager under the Processes window, not the Application
window. I also tried adding a call to Process.GetProcesses() to see
all the processes on the system. I do NOT see that process in the
array returned. Should I see a process with the name of App1.exe?

Thanks for the help,

Chris

Oct 11 '06 #1
  • viewed: 6283
Share:
1 Reply
Today I put in a Thread.Sleep(xxx) call before I go get the processes
with GetProcesses() and it is finding my App1 process. I would still
prefer to just be able to do a _proc.WaitForExit() right after I do the
_proc.Start(), but that isn't working.

If someone knows why, I would still like an answer.

Thanks,

Chris
Chris wrote:
Hello,

I have a Windows Forms application which has buttons to click to run
other programs.

One of the applications it must run is a ClickOnce Windows Forms
application, so the Application Reference in the start menu is the only
way to access it.

I have the following code used to start the other program:

System.Diagnostics.Process _proc;
string ExecutableName;

ExecutableName = "C:\\Documents and
Settings\\User\\Start Menu\\Programs\\App1\\App1.appref-ms";
_proc = new System.Diagnostics.Process();
_proc.StartInfo.FileName = ExecutableName;
_proc.StartInfo.UseShellExecute = true;
_proc.StartInfo.WindowStyle =
ProcessWindowStyle.Normal;
_proc.Start();

It DOES successfully start the application. The original Forms
Application must WAIT on the other program, so I added the following
line:

_proc.WaitForExit();

When it executes that line, I get an Exception "No process is
associated with this object".

If I execute an old VB6 application instead of the ClickOnce
application, _proc contains valid information and the WaitForExit works
fine. What is the problem here?

One thing I have noticed is that the ClickOnce application only shows
up in Task Manager under the Processes window, not the Application
window. I also tried adding a call to Process.GetProcesses() to see
all the processes on the system. I do NOT see that process in the
array returned. Should I see a process with the name of App1.exe?

Thanks for the help,

Chris
Oct 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by jcrouse | last post: by
1 post views Thread by John Crouse | last post: by
7 posts views Thread by Bob | last post: by
9 posts views Thread by Eran.Yasso@gmail.com | last post: by
5 posts views Thread by andrew | last post: by
1 post views Thread by =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.