473,326 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

Similar topics

3
by: James Li | last post by:
I have the code below, the first process takes about 10 minutes to finish. But the waitForExit doesn't seem to wait when I debug the program, it go immediately to execute code after the...
6
by: jcrouse | last post by:
This is kind of a continuation of another thread that was somewhat resolved: Well, the dilemma seems to be this. I want to be able to hide the DOS box AND pause the code until execution is...
1
by: John Crouse | last post by:
I am using the following code sucessfully on Windows 2000 and Windows XP. However, in WIndows 98 it seems to hang on the WaitForExit. What are my options here? MsgBox("Please be patient. This...
2
by: Terry Olsen | last post by:
Using the following code, I get the error "No process is associated with this object" when calling the WinZip.WaitForExit() method. After I click the "Break" or "Continue" button on the dialog,...
7
by: Bob | last post by:
Process.start("Mydoc.doc") starts Word with the file. I need to wait for Word to be closed before more code can execute in my app. How can I do this? Thanks for any help Bob
9
by: Eran.Yasso | last post by:
Hi, My app starts process. Some times this process exits because of exception. Can my app know if the process exited due to exception or gracefully? In both ways, the exit code of this...
5
by: andrew | last post by:
Hi, I have the following issue with the Thread.Abort(): The main thread creates a worker thread which waits on a process termination. void ThreadProc() { Process proc =...
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a C# application in which I start another process which produces output to stdout and stderr. In fact, that process is the uSoft VS2005 C/C++ compiler itself! I would like to...
4
by: Steven De Smet | last post by:
Hello, This is my first post. I searched on the internet for answers but I was unable to solve my problem. So I hope that you guy's can help me with my VB.NET problem I tried to create a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.