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

C# Process.Start (applications return code to OS)

P: n/a
I am running an application called AcroComm.exe to poll time clocks here at
our company. I have written a small C# app that will poll the clocks based
on information found in a DB. My problem is that AcroComm will sometimes
stop polling in the middle of the process and terminate. The programing
manual for the app says that it sends a code to the operating system when it
is done that tells what has happend like the following:

0 success
13 aborted
etc...

When it aborts the downloading, my program doesn't know it, it just goes to
the next line of code and continues to poll the next clock. I am using code
like this: System.Diagnostics.Process.Start("AppPath\Name", "Command Line
Parameters")

How can I hook in and see what the code was that the process returned to the
operating system? If you need more info or an exact snipet of code, please
feel free to ask.

Anthony
Nov 17 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Anthony,

You have two options here. The first is to get the Process instance and
call the WaitForExit method. This will block the current thread until the
process has completed.

The second option is to register for the Exited event (make sure you set
EnableRaisingEvents on the process to true).

Whichever you decide to do, when these events occur, you can check the
value of the ExitCode property to see what was returned to the OS.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl...
I am running an application called AcroComm.exe to poll time clocks here at
our company. I have written a small C# app that will poll the clocks based
on information found in a DB. My problem is that AcroComm will sometimes
stop polling in the middle of the process and terminate. The programing
manual for the app says that it sends a code to the operating system when
it
is done that tells what has happend like the following:

0 success
13 aborted
etc...

When it aborts the downloading, my program doesn't know it, it just goes
to
the next line of code and continues to poll the next clock. I am using
code
like this: System.Diagnostics.Process.Start("AppPath\Name", "Command Line
Parameters")

How can I hook in and see what the code was that the process returned to
the
operating system? If you need more info or an exact snipet of code, please
feel free to ask.

Anthony

Nov 17 '05 #2

P: n/a
Thanks Nicholas,

I am still fairly new to C#... Could you perhaps provide me with an example
of this or point me in the right direction to read it?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:el**************@TK2MSFTNGP14.phx.gbl...
Anthony,

You have two options here. The first is to get the Process instance and call the WaitForExit method. This will block the current thread until the
process has completed.

The second option is to register for the Exited event (make sure you set EnableRaisingEvents on the process to true).

Whichever you decide to do, when these events occur, you can check the
value of the ExitCode property to see what was returned to the OS.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl...
I am running an application called AcroComm.exe to poll time clocks here at our company. I have written a small C# app that will poll the clocks based on information found in a DB. My problem is that AcroComm will sometimes
stop polling in the middle of the process and terminate. The programing
manual for the app says that it sends a code to the operating system when it
is done that tells what has happend like the following:

0 success
13 aborted
etc...

When it aborts the downloading, my program doesn't know it, it just goes
to
the next line of code and continues to poll the next clock. I am using
code
like this: System.Diagnostics.Process.Start("AppPath\Name", "Command Line Parameters")

How can I hook in and see what the code was that the process returned to
the
operating system? If you need more info or an exact snipet of code, please feel free to ask.

Anthony


Nov 17 '05 #3

P: n/a
Tony,

Instead of doing this:

System.Diagnostics.Process.Start("AppPath\Name", "Command Line Parameters");

Do this:

// Create the process.
using (Process process = Process.Start("AppPath\Name", "Command Line
Parameters"))
{
// Wait for the process to complete.
process.WaitForExit();

// Access the ExitCode property here to get the exit code from the
application you ran.
}
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
Thanks Nicholas,

I am still fairly new to C#... Could you perhaps provide me with an
example
of this or point me in the right direction to read it?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:el**************@TK2MSFTNGP14.phx.gbl...
Anthony,

You have two options here. The first is to get the Process instance

and
call the WaitForExit method. This will block the current thread until
the
process has completed.

The second option is to register for the Exited event (make sure you

set
EnableRaisingEvents on the process to true).

Whichever you decide to do, when these events occur, you can check
the
value of the ExitCode property to see what was returned to the OS.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl...
>I am running an application called AcroComm.exe to poll time clocks here at > our company. I have written a small C# app that will poll the clocks based > on information found in a DB. My problem is that AcroComm will
> sometimes
> stop polling in the middle of the process and terminate. The
> programing
> manual for the app says that it sends a code to the operating system when > it
> is done that tells what has happend like the following:
>
> 0 success
> 13 aborted
> etc...
>
> When it aborts the downloading, my program doesn't know it, it just
> goes
> to
> the next line of code and continues to poll the next clock. I am using
> code
> like this: System.Diagnostics.Process.Start("AppPath\Name", "Command Line > Parameters")
>
> How can I hook in and see what the code was that the process returned
> to
> the
> operating system? If you need more info or an exact snipet of code, please > feel free to ask.
>
> Anthony
>
>



Nov 17 '05 #4

P: n/a
Thanks again... I think I understand now.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Tony,

Instead of doing this:

System.Diagnostics.Process.Start("AppPath\Name", "Command Line Parameters");
Do this:

// Create the process.
using (Process process = Process.Start("AppPath\Name", "Command Line
Parameters"))
{
// Wait for the process to complete.
process.WaitForExit();

// Access the ExitCode property here to get the exit code from the
application you ran.
}
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
Thanks Nicholas,

I am still fairly new to C#... Could you perhaps provide me with an
example
of this or point me in the right direction to read it?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:el**************@TK2MSFTNGP14.phx.gbl...
Anthony,

You have two options here. The first is to get the Process instance
and
call the WaitForExit method. This will block the current thread until
the
process has completed.

The second option is to register for the Exited event (make sure
you set
EnableRaisingEvents on the process to true).

Whichever you decide to do, when these events occur, you can check
the
value of the ExitCode property to see what was returned to the OS.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl...
>I am running an application called AcroComm.exe to poll time clocks
here at
> our company. I have written a small C# app that will poll the clocks

based
> on information found in a DB. My problem is that AcroComm will
> sometimes
> stop polling in the middle of the process and terminate. The
> programing
> manual for the app says that it sends a code to the operating system

when
> it
> is done that tells what has happend like the following:
>
> 0 success
> 13 aborted
> etc...
>
> When it aborts the downloading, my program doesn't know it, it just
> goes
> to
> the next line of code and continues to poll the next clock. I am

using > code
> like this: System.Diagnostics.Process.Start("AppPath\Name", "Command

Line
> Parameters")
>
> How can I hook in and see what the code was that the process returned
> to
> the
> operating system? If you need more info or an exact snipet of code,

please
> feel free to ask.
>
> Anthony
>
>



Nov 17 '05 #5

P: n/a
Nicholas,

I am curious, I did follow the example which seemed to work and try polling
a clock that I knew wasn't online and one that was. I got the 0 for
successful for the clock online but I still got a 0 for hte one that wasn't.
I am wondering, is this 0 like a bool that lets me know that the process has
exited on it's own.. If so, that isn't necesarrily what I am wanting, I need
the code that is sent to the OS from the application (which could be one of
about 15) I am running from a process.start

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Tony,

Instead of doing this:

System.Diagnostics.Process.Start("AppPath\Name", "Command Line Parameters");
Do this:

// Create the process.
using (Process process = Process.Start("AppPath\Name", "Command Line
Parameters"))
{
// Wait for the process to complete.
process.WaitForExit();

// Access the ExitCode property here to get the exit code from the
application you ran.
}
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
Thanks Nicholas,

I am still fairly new to C#... Could you perhaps provide me with an
example
of this or point me in the right direction to read it?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:el**************@TK2MSFTNGP14.phx.gbl...
Anthony,

You have two options here. The first is to get the Process instance
and
call the WaitForExit method. This will block the current thread until
the
process has completed.

The second option is to register for the Exited event (make sure
you set
EnableRaisingEvents on the process to true).

Whichever you decide to do, when these events occur, you can check
the
value of the ExitCode property to see what was returned to the OS.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl...
>I am running an application called AcroComm.exe to poll time clocks
here at
> our company. I have written a small C# app that will poll the clocks

based
> on information found in a DB. My problem is that AcroComm will
> sometimes
> stop polling in the middle of the process and terminate. The
> programing
> manual for the app says that it sends a code to the operating system

when
> it
> is done that tells what has happend like the following:
>
> 0 success
> 13 aborted
> etc...
>
> When it aborts the downloading, my program doesn't know it, it just
> goes
> to
> the next line of code and continues to poll the next clock. I am

using > code
> like this: System.Diagnostics.Process.Start("AppPath\Name", "Command

Line
> Parameters")
>
> How can I hook in and see what the code was that the process returned
> to
> the
> operating system? If you need more info or an exact snipet of code,

please
> feel free to ask.
>
> Anthony
>
>



Nov 17 '05 #6

P: n/a
Hi,

The value as well as the meaning depend of the application.

A return value of 0 is the standard (inherited from Unix) to indicate a
succesful execution.

do this, create a small command app that only set the return value (
Environment.ExitCode ) and see if your code is reading it correctly.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Tony" <as*******@hardenmfg.com> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl...
Nicholas,

I am curious, I did follow the example which seemed to work and try
polling
a clock that I knew wasn't online and one that was. I got the 0 for
successful for the clock online but I still got a 0 for hte one that
wasn't.
I am wondering, is this 0 like a bool that lets me know that the process
has
exited on it's own.. If so, that isn't necesarrily what I am wanting, I
need
the code that is sent to the OS from the application (which could be one
of
about 15) I am running from a process.start

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Tony,

Instead of doing this:

System.Diagnostics.Process.Start("AppPath\Name", "Command Line

Parameters");

Do this:

// Create the process.
using (Process process = Process.Start("AppPath\Name", "Command Line
Parameters"))
{
// Wait for the process to complete.
process.WaitForExit();

// Access the ExitCode property here to get the exit code from the
application you ran.
}
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
> Thanks Nicholas,
>
> I am still fairly new to C#... Could you perhaps provide me with an
> example
> of this or point me in the right direction to read it?
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:el**************@TK2MSFTNGP14.phx.gbl...
>> Anthony,
>>
>> You have two options here. The first is to get the Process instance > and
>> call the WaitForExit method. This will block the current thread until
>> the
>> process has completed.
>>
>> The second option is to register for the Exited event (make sure you > set
>> EnableRaisingEvents on the process to true).
>>
>> Whichever you decide to do, when these events occur, you can check
>> the
>> value of the ExitCode property to see what was returned to the OS.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Tony" <as*******@hardenmfg.com> wrote in message
>> news:eC**************@TK2MSFTNGP09.phx.gbl...
>> >I am running an application called AcroComm.exe to poll time clocks here > at
>> > our company. I have written a small C# app that will poll the clocks
> based
>> > on information found in a DB. My problem is that AcroComm will
>> > sometimes
>> > stop polling in the middle of the process and terminate. The
>> > programing
>> > manual for the app says that it sends a code to the operating system
> when
>> > it
>> > is done that tells what has happend like the following:
>> >
>> > 0 success
>> > 13 aborted
>> > etc...
>> >
>> > When it aborts the downloading, my program doesn't know it, it just
>> > goes
>> > to
>> > the next line of code and continues to poll the next clock. I am using >> > code
>> > like this: System.Diagnostics.Process.Start("AppPath\Name", "Command
> Line
>> > Parameters")
>> >
>> > How can I hook in and see what the code was that the process
>> > returned
>> > to
>> > the
>> > operating system? If you need more info or an exact snipet of code,
> please
>> > feel free to ask.
>> >
>> > Anthony
>> >
>> >
>>
>>
>
>



Nov 17 '05 #7

P: n/a
Tony,

I just tried an example here, and it worked fine. Are you sure that the
code that is returned is the exit code of the process, or is that code
returned in some other manner?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl...
Nicholas,

I am curious, I did follow the example which seemed to work and try
polling
a clock that I knew wasn't online and one that was. I got the 0 for
successful for the clock online but I still got a 0 for hte one that
wasn't.
I am wondering, is this 0 like a bool that lets me know that the process
has
exited on it's own.. If so, that isn't necesarrily what I am wanting, I
need
the code that is sent to the OS from the application (which could be one
of
about 15) I am running from a process.start

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Tony,

Instead of doing this:

System.Diagnostics.Process.Start("AppPath\Name", "Command Line

Parameters");

Do this:

// Create the process.
using (Process process = Process.Start("AppPath\Name", "Command Line
Parameters"))
{
// Wait for the process to complete.
process.WaitForExit();

// Access the ExitCode property here to get the exit code from the
application you ran.
}
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
> Thanks Nicholas,
>
> I am still fairly new to C#... Could you perhaps provide me with an
> example
> of this or point me in the right direction to read it?
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:el**************@TK2MSFTNGP14.phx.gbl...
>> Anthony,
>>
>> You have two options here. The first is to get the Process instance > and
>> call the WaitForExit method. This will block the current thread until
>> the
>> process has completed.
>>
>> The second option is to register for the Exited event (make sure you > set
>> EnableRaisingEvents on the process to true).
>>
>> Whichever you decide to do, when these events occur, you can check
>> the
>> value of the ExitCode property to see what was returned to the OS.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Tony" <as*******@hardenmfg.com> wrote in message
>> news:eC**************@TK2MSFTNGP09.phx.gbl...
>> >I am running an application called AcroComm.exe to poll time clocks here > at
>> > our company. I have written a small C# app that will poll the clocks
> based
>> > on information found in a DB. My problem is that AcroComm will
>> > sometimes
>> > stop polling in the middle of the process and terminate. The
>> > programing
>> > manual for the app says that it sends a code to the operating system
> when
>> > it
>> > is done that tells what has happend like the following:
>> >
>> > 0 success
>> > 13 aborted
>> > etc...
>> >
>> > When it aborts the downloading, my program doesn't know it, it just
>> > goes
>> > to
>> > the next line of code and continues to poll the next clock. I am using >> > code
>> > like this: System.Diagnostics.Process.Start("AppPath\Name", "Command
> Line
>> > Parameters")
>> >
>> > How can I hook in and see what the code was that the process
>> > returned
>> > to
>> > the
>> > operating system? If you need more info or an exact snipet of code,
> please
>> > feel free to ask.
>> >
>> > Anthony
>> >
>> >
>>
>>
>
>



Nov 17 '05 #8

P: n/a
Well, I am unsure. The manual states the following: "Acrocomm feeds back the
following codes to the operating system" and then it lists the codes. That
is all it says in that section. It has no further descriptions. There is
also nothing listed before this and the heading of the section is "Error
Codes"!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uS**************@TK2MSFTNGP09.phx.gbl...
Tony,

I just tried an example here, and it worked fine. Are you sure that the code that is returned is the exit code of the process, or is that code
returned in some other manner?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl...
Nicholas,

I am curious, I did follow the example which seemed to work and try
polling
a clock that I knew wasn't online and one that was. I got the 0 for
successful for the clock online but I still got a 0 for hte one that
wasn't.
I am wondering, is this 0 like a bool that lets me know that the process
has
exited on it's own.. If so, that isn't necesarrily what I am wanting, I
need
the code that is sent to the OS from the application (which could be one
of
about 15) I am running from a process.start

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Tony,

Instead of doing this:

System.Diagnostics.Process.Start("AppPath\Name", "Command Line

Parameters");

Do this:

// Create the process.
using (Process process = Process.Start("AppPath\Name", "Command Line
Parameters"))
{
// Wait for the process to complete.
process.WaitForExit();

// Access the ExitCode property here to get the exit code from the
application you ran.
}
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
> Thanks Nicholas,
>
> I am still fairly new to C#... Could you perhaps provide me with an
> example
> of this or point me in the right direction to read it?
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:el**************@TK2MSFTNGP14.phx.gbl...
>> Anthony,
>>
>> You have two options here. The first is to get the Process

instance
> and
>> call the WaitForExit method. This will block the current thread until >> the
>> process has completed.
>>
>> The second option is to register for the Exited event (make sure

you
> set
>> EnableRaisingEvents on the process to true).
>>
>> Whichever you decide to do, when these events occur, you can check >> the
>> value of the ExitCode property to see what was returned to the OS.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Tony" <as*******@hardenmfg.com> wrote in message
>> news:eC**************@TK2MSFTNGP09.phx.gbl...
>> >I am running an application called AcroComm.exe to poll time clocks

here
> at
>> > our company. I have written a small C# app that will poll the clocks > based
>> > on information found in a DB. My problem is that AcroComm will
>> > sometimes
>> > stop polling in the middle of the process and terminate. The
>> > programing
>> > manual for the app says that it sends a code to the operating system > when
>> > it
>> > is done that tells what has happend like the following:
>> >
>> > 0 success
>> > 13 aborted
>> > etc...
>> >
>> > When it aborts the downloading, my program doesn't know it, it just >> > goes
>> > to
>> > the next line of code and continues to poll the next clock. I am

using
>> > code
>> > like this: System.Diagnostics.Process.Start("AppPath\Name", "Command > Line
>> > Parameters")
>> >
>> > How can I hook in and see what the code was that the process
>> > returned
>> > to
>> > the
>> > operating system? If you need more info or an exact snipet of code, > please
>> > feel free to ask.
>> >
>> > Anthony
>> >
>> >
>>
>>
>
>



Nov 17 '05 #9

P: n/a
Tony,

Is it possible that it does it through the out or err output streams and
not as a return code?

If it doesn't return this value through the return value of the
application, then there has to be some other way. You need to find what
that way is (unless someone else here is familiar with the product in
question).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:ev**************@TK2MSFTNGP14.phx.gbl...
Well, I am unsure. The manual states the following: "Acrocomm feeds back
the
following codes to the operating system" and then it lists the codes. That
is all it says in that section. It has no further descriptions. There is
also nothing listed before this and the heading of the section is "Error
Codes"!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:uS**************@TK2MSFTNGP09.phx.gbl...
Tony,

I just tried an example here, and it worked fine. Are you sure that

the
code that is returned is the exit code of the process, or is that code
returned in some other manner?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl...
> Nicholas,
>
> I am curious, I did follow the example which seemed to work and try
> polling
> a clock that I knew wasn't online and one that was. I got the 0 for
> successful for the clock online but I still got a 0 for hte one that
> wasn't.
> I am wondering, is this 0 like a bool that lets me know that the
> process
> has
> exited on it's own.. If so, that isn't necesarrily what I am wanting, I
> need
> the code that is sent to the OS from the application (which could be
> one
> of
> about 15) I am running from a process.start
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:%2****************@TK2MSFTNGP09.phx.gbl...
>> Tony,
>>
>> Instead of doing this:
>>
>> System.Diagnostics.Process.Start("AppPath\Name", "Command Line
> Parameters");
>>
>> Do this:
>>
>> // Create the process.
>> using (Process process = Process.Start("AppPath\Name", "Command Line
>> Parameters"))
>> {
>> // Wait for the process to complete.
>> process.WaitForExit();
>>
>> // Access the ExitCode property here to get the exit code from the
>> application you ran.
>> }
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Tony" <as*******@hardenmfg.com> wrote in message
>> news:eA**************@tk2msftngp13.phx.gbl...
>> > Thanks Nicholas,
>> >
>> > I am still fairly new to C#... Could you perhaps provide me with an
>> > example
>> > of this or point me in the right direction to read it?
>> >
>> >
>> > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
>> > wrote
>> > in
>> > message news:el**************@TK2MSFTNGP14.phx.gbl...
>> >> Anthony,
>> >>
>> >> You have two options here. The first is to get the Process
> instance
>> > and
>> >> call the WaitForExit method. This will block the current thread until >> >> the
>> >> process has completed.
>> >>
>> >> The second option is to register for the Exited event (make
>> >> sure
> you
>> > set
>> >> EnableRaisingEvents on the process to true).
>> >>
>> >> Whichever you decide to do, when these events occur, you can check >> >> the
>> >> value of the ExitCode property to see what was returned to the OS.
>> >>
>> >> Hope this helps.
>> >>
>> >>
>> >> --
>> >> - Nicholas Paldino [.NET/C# MVP]
>> >> - mv*@spam.guard.caspershouse.com
>> >>
>> >> "Tony" <as*******@hardenmfg.com> wrote in message
>> >> news:eC**************@TK2MSFTNGP09.phx.gbl...
>> >> >I am running an application called AcroComm.exe to poll time
>> >> >clocks
> here
>> > at
>> >> > our company. I have written a small C# app that will poll the clocks >> > based
>> >> > on information found in a DB. My problem is that AcroComm will
>> >> > sometimes
>> >> > stop polling in the middle of the process and terminate. The
>> >> > programing
>> >> > manual for the app says that it sends a code to the operating system >> > when
>> >> > it
>> >> > is done that tells what has happend like the following:
>> >> >
>> >> > 0 success
>> >> > 13 aborted
>> >> > etc...
>> >> >
>> >> > When it aborts the downloading, my program doesn't know it, it just >> >> > goes
>> >> > to
>> >> > the next line of code and continues to poll the next clock. I am
> using
>> >> > code
>> >> > like this: System.Diagnostics.Process.Start("AppPath\Name", "Command >> > Line
>> >> > Parameters")
>> >> >
>> >> > How can I hook in and see what the code was that the process
>> >> > returned
>> >> > to
>> >> > the
>> >> > operating system? If you need more info or an exact snipet of code, >> > please
>> >> > feel free to ask.
>> >> >
>> >> > Anthony
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 17 '05 #10

P: n/a
I am currently testing the standardError output to see if it may be in
there...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ew**************@TK2MSFTNGP10.phx.gbl...
Tony,

Is it possible that it does it through the out or err output streams and not as a return code?

If it doesn't return this value through the return value of the
application, then there has to be some other way. You need to find what
that way is (unless someone else here is familiar with the product in
question).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:ev**************@TK2MSFTNGP14.phx.gbl...
Well, I am unsure. The manual states the following: "Acrocomm feeds back
the
following codes to the operating system" and then it lists the codes. That is all it says in that section. It has no further descriptions. There is
also nothing listed before this and the heading of the section is "Error
Codes"!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:uS**************@TK2MSFTNGP09.phx.gbl...
Tony,

I just tried an example here, and it worked fine. Are you sure that
the
code that is returned is the exit code of the process, or is that code
returned in some other manner?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony" <as*******@hardenmfg.com> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl...
> Nicholas,
>
> I am curious, I did follow the example which seemed to work and try
> polling
> a clock that I knew wasn't online and one that was. I got the 0 for
> successful for the clock online but I still got a 0 for hte one that
> wasn't.
> I am wondering, is this 0 like a bool that lets me know that the
> process
> has
> exited on it's own.. If so, that isn't necesarrily what I am wanting,

I > need
> the code that is sent to the OS from the application (which could be
> one
> of
> about 15) I am running from a process.start
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:%2****************@TK2MSFTNGP09.phx.gbl...
>> Tony,
>>
>> Instead of doing this:
>>
>> System.Diagnostics.Process.Start("AppPath\Name", "Command Line
> Parameters");
>>
>> Do this:
>>
>> // Create the process.
>> using (Process process = Process.Start("AppPath\Name", "Command Line
>> Parameters"))
>> {
>> // Wait for the process to complete.
>> process.WaitForExit();
>>
>> // Access the ExitCode property here to get the exit code from the >> application you ran.
>> }
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Tony" <as*******@hardenmfg.com> wrote in message
>> news:eA**************@tk2msftngp13.phx.gbl...
>> > Thanks Nicholas,
>> >
>> > I am still fairly new to C#... Could you perhaps provide me with an >> > example
>> > of this or point me in the right direction to read it?
>> >
>> >
>> > "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
>> > wrote
>> > in
>> > message news:el**************@TK2MSFTNGP14.phx.gbl...
>> >> Anthony,
>> >>
>> >> You have two options here. The first is to get the Process
> instance
>> > and
>> >> call the WaitForExit method. This will block the current thread

until
>> >> the
>> >> process has completed.
>> >>
>> >> The second option is to register for the Exited event (make
>> >> sure
> you
>> > set
>> >> EnableRaisingEvents on the process to true).
>> >>
>> >> Whichever you decide to do, when these events occur, you can

check
>> >> the
>> >> value of the ExitCode property to see what was returned to the OS. >> >>
>> >> Hope this helps.
>> >>
>> >>
>> >> --
>> >> - Nicholas Paldino [.NET/C# MVP]
>> >> - mv*@spam.guard.caspershouse.com
>> >>
>> >> "Tony" <as*******@hardenmfg.com> wrote in message
>> >> news:eC**************@TK2MSFTNGP09.phx.gbl...
>> >> >I am running an application called AcroComm.exe to poll time
>> >> >clocks
> here
>> > at
>> >> > our company. I have written a small C# app that will poll the

clocks
>> > based
>> >> > on information found in a DB. My problem is that AcroComm will
>> >> > sometimes
>> >> > stop polling in the middle of the process and terminate. The
>> >> > programing
>> >> > manual for the app says that it sends a code to the operating

system
>> > when
>> >> > it
>> >> > is done that tells what has happend like the following:
>> >> >
>> >> > 0 success
>> >> > 13 aborted
>> >> > etc...
>> >> >
>> >> > When it aborts the downloading, my program doesn't know it, it

just
>> >> > goes
>> >> > to
>> >> > the next line of code and continues to poll the next clock. I am > using
>> >> > code
>> >> > like this: System.Diagnostics.Process.Start("AppPath\Name",

"Command
>> > Line
>> >> > Parameters")
>> >> >
>> >> > How can I hook in and see what the code was that the process
>> >> > returned
>> >> > to
>> >> > the
>> >> > operating system? If you need more info or an exact snipet of

code,
>> > please
>> >> > feel free to ask.
>> >> >
>> >> > Anthony
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.