473,898 Members | 2,551 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
10 15929
I am currently testing the standardError output to see if it may be in
there...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:ew******** ******@TK2MSFTN GP10.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.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 #11

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
5943
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
2269
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
3853
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
3550
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
12214
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
1407
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
9993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9840
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10857
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10948
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
9661
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...
0
7187
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
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4295
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3305
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.