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
> >> >
> >> >
> >>
> >>
> >
> >
>
>


.



Relevant Pages

  • Re: Tuesday Top 5: Dreamcast Games
    ... Phantasy Star Online ... given a helping hand by higher level players, none of whom seemed to mind my ... If only more recent online games had managed to ... clock aspect. ...
    (uk.games.video.misc)
  • Re: clock stopped on ibook G3
    ... later corrects when online. ... clock sets because the Time server ist activated in "Date & time" ... It does not make sense because iBooks have no ... EDV-Dienstleistungen, Hard- und Software, Internet und Netzwerk ...
    (comp.sys.mac.portables)
  • Re: 24 hour time
    ... The display outside my local Sainsbury's uses "am/pm" times, ... another for the online one. ... 24-hour clock; I got bored, but not before finding Asda use am & pm. ...
    (alt.usage.english)
  • Re: XBLA Multiplayer
    ... Sign out of your profile so you can change the clock on your xbox. ... Start BF without signing in and then sign in when it asks for it presto my game works again. ... EA are complete rubbish to be honest with all these extra requirements, when I changed my email address on Live I lost the linkup between my EA online account (which tracks stats BF1943 stats) entirely. ...
    (uk.games.video.misc)
  • Re: windows search issues
    ... Is this search a P2P search, if so right click under the clock then go to ... > also everytime i go online through my dialup it says i cannot connect due ... > i am working offline, i go online on AOL but it is IE that is defaulting ... also I am not very good with computers ...
    (microsoft.public.windowsxp.general)