473,883 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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
10 15927
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
EnableRaisingEv ents 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.co m

"Tony" <as*******@hard enmfg.com> wrote in message
news:eC******** ******@TK2MSFTN GP09.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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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
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.c om> wrote in
message news:el******** ******@TK2MSFTN GP14.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 EnableRaisingEv ents 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.co m

"Tony" <as*******@hard enmfg.com> wrote in message
news:eC******** ******@TK2MSFTN GP09.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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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
Tony,

Instead of doing this:

System.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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.WaitFor Exit();

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

"Tony" <as*******@hard enmfg.com> wrote in message
news:eA******** ******@tk2msftn gp13.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.c om> wrote
in
message news:el******** ******@TK2MSFTN GP14.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
EnableRaisingEv ents 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.co m

"Tony" <as*******@hard enmfg.com> wrote in message
news:eC******** ******@TK2MSFTN GP09.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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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
Thanks again... I think I understand now.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Tony,

Instead of doing this:

System.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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.WaitFor Exit();

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

"Tony" <as*******@hard enmfg.com> wrote in message
news:eA******** ******@tk2msftn gp13.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.c om> wrote
in
message news:el******** ******@TK2MSFTN GP14.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
EnableRaisingEv ents 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.co m

"Tony" <as*******@hard enmfg.com> wrote in message
news:eC******** ******@TK2MSFTN GP09.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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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
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.c om> wrote in
message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Tony,

Instead of doing this:

System.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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.WaitFor Exit();

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

"Tony" <as*******@hard enmfg.com> wrote in message
news:eA******** ******@tk2msftn gp13.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.c om> wrote
in
message news:el******** ******@TK2MSFTN GP14.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
EnableRaisingEv ents 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.co m

"Tony" <as*******@hard enmfg.com> wrote in message
news:eC******** ******@TK2MSFTN GP09.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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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
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.Exi tCode ) 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*******@hard enmfg.com> wrote in message
news:uv******** ******@TK2MSFTN GP12.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.c om> wrote
in
message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Tony,

Instead of doing this:

System.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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.WaitFor Exit();

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

"Tony" <as*******@hard enmfg.com> wrote in message
news:eA******** ******@tk2msftn gp13.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.c om>
> wrote
> in
> message news:el******** ******@TK2MSFTN GP14.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
>> EnableRaisingEv ents 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.co m
>>
>> "Tony" <as*******@hard enmfg.com> wrote in message
>> news:eC******** ******@TK2MSFTN GP09.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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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
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.co m

"Tony" <as*******@hard enmfg.com> wrote in message
news:uv******** ******@TK2MSFTN GP12.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.c om> wrote
in
message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Tony,

Instead of doing this:

System.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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.WaitFor Exit();

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

"Tony" <as*******@hard enmfg.com> wrote in message
news:eA******** ******@tk2msftn gp13.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.c om>
> wrote
> in
> message news:el******** ******@TK2MSFTN GP14.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
>> EnableRaisingEv ents 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.co m
>>
>> "Tony" <as*******@hard enmfg.com> wrote in message
>> news:eC******** ******@TK2MSFTN GP09.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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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
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.c om> wrote in
message news:uS******** ******@TK2MSFTN GP09.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.co m

"Tony" <as*******@hard enmfg.com> wrote in message
news:uv******** ******@TK2MSFTN GP12.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.c om> wrote
in
message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Tony,

Instead of doing this:

System.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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.WaitFor Exit();

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

"Tony" <as*******@hard enmfg.com> wrote in message
news:eA******** ******@tk2msftn gp13.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.c om>
> wrote
> in
> message news:el******** ******@TK2MSFTN GP14.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
>> EnableRaisingEv ents 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.co m
>>
>> "Tony" <as*******@hard enmfg.com> wrote in message
>> news:eC******** ******@TK2MSFTN GP09.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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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
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.co m

"Tony" <as*******@hard enmfg.com> wrote in message
news:ev******** ******@TK2MSFTN GP14.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.c om> wrote
in
message news:uS******** ******@TK2MSFTN GP09.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.co m

"Tony" <as*******@hard enmfg.com> wrote in message
news:uv******** ******@TK2MSFTN GP12.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.c om>
> wrote
> in
> message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
>> Tony,
>>
>> Instead of doing this:
>>
>> System.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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.WaitFor Exit();
>>
>> // Access the ExitCode property here to get the exit code from the
>> application you ran.
>> }
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard. caspershouse.co m
>>
>> "Tony" <as*******@hard enmfg.com> wrote in message
>> news:eA******** ******@tk2msftn gp13.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.c om>
>> > wrote
>> > in
>> > message news:el******** ******@TK2MSFTN GP14.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
>> >> EnableRaisingEv ents 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.co m
>> >>
>> >> "Tony" <as*******@hard enmfg.com> wrote in message
>> >> news:eC******** ******@TK2MSFTN GP09.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.Diagnost ics.Process.Sta rt("AppPath\Nam e", "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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3209
by: Tobias Johansson | last post by:
Hello, I'm having what I believe a security problem to execute an executable file from a windows service in windows server 2003. It works fine in WIN XP SP2 The program(the service) itself just continues as if nothing where wrong after process.Start is executed and I get an Exit code from the process
3
5942
by: Manfred Braun | last post by:
Hi All, the Process.Start method returns a boolean value to indicate, if a process was started or not. Where can I obtain more detailed error information, if the process could not be started ??? It seems to be possible, that a Win32Exception will be thrown. Will this give me this reason , if the process cannot be started? The docs looks a little vage for me. Thanks in advance, Manfred Braun
2
2477
by: brian.gabriel | last post by:
I am trying to kick of a DOS program from a VB.Net service. The program works fine when called from a batch file, and from a Windows form, but it has problems when called from a service. The program runs successfully but does not give control back to the service. After the Process.Start statement no code will execute. The program has exited and is not shown in process monitor. I am running the service under an admin account. See...
0
2268
by: henning.friese | last post by:
Hello NG, I'm need to write some code which creates tiff files from various document types (doc, pdf, xls). I want to do this by ShellExecuting (via System.Diagnostics.Process) the doc-files with the "print"-verb. This works for me. However, I need to handle the case when a printing application doesnt't quit in a given timespan (for example a password-protected word-document). So I've tried the following:
5
2642
by: Vijaya P Krishna | last post by:
Hi, I have a .NET Windows Forms application, written in VB.NET and C#. I am opening a URL from the application using Process.Start(). The URL points to a java servlet running on apache-tomcat. For some users the application shows an error dialog with following information. Another very interesting observation is that it's sending a lot of requests to the servlet within no time. Please note that this is not happening for all users.
3
3851
by: LoDawg | last post by:
I am using the system.diagnostics.process.start command to launch an excel template. Once open the user has the option to create a new template through a wizard I have created. When the wizard finishes it goes back through the same routine to open the new template. Everything works fine until it reaches the process.start line of code then it just freezes. I assume this is because the process (Excel) is already started. I am looking for a...
6
3548
by: Leonel Galán | last post by:
When doing Process.Start(), I get "The parameter is invalid" Win32Exception when opening a particular exe. This exe works good in Windows (cmd.exe). The exe is "SPIM.exe" as the Simulator for the MIPS assembling language (http://www.cs.wisc.edu/~larus/spim.html). I know that maybe that particular file has something strange, but I thought someone could give me some advice.
2
12211
by: Kerem Gümrükcü | last post by:
Hi, i have a Process.Start call that fails with 267 Error Code if invoked with another user and password other than the applications user. It is a ordinary piece of code just create a Process Object , fill its StartInfo and then go a process.Start(), It works fine, unless i try to execute the process with another user. Why, what do i have to take care of,...i gt the 267 Win32Exception Code with the Exception thrown,...
2
1406
by: SirBe | last post by:
I'm making a mod manager for Cortex Command. When I try to start the game using Process.Start(), I get an error in Cortex Command (not my program). http://img167.imageshack.us/img167/3531/fffffte6.png I'm assuming that Settings.ini is the first file that Cortex Command reads from, so there's obviously some issue with Cortex Command reading from files when executed from the shell. I either need a fix for this, or an alternative method...
0
11141
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9573
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7971
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7126
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5797
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5991
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3232
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.