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



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]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:%234pxA4GlFHA.3288@xxxxxxxxxxxxxxxxxxxxxxx
> 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]
> - mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> "Tony" <asizemore@xxxxxxxxxxxxx> wrote in message
> news:eAj6zzGlFHA.2904@xxxxxxxxxxxxxxxxxxxxxxx
> > 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]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote
> > in
> > message news:elu46xGlFHA.1440@xxxxxxxxxxxxxxxxxxxxxxx
> >> 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]
> >> - mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
> >>
> >> "Tony" <asizemore@xxxxxxxxxxxxx> wrote in message
> >> news:eCASksGlFHA.3288@xxxxxxxxxxxxxxxxxxxxxxx
> >> >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
> >> >
> >> >
> >>
> >>
> >
> >
>
>


.