Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear Friends,

I am having a problem...
Well I cant call it a problem.
I am scheduling an Application which I have made, using Windows Scheduler, and I am returning some values depending on the number of records affected.
It runs as a service, and creates a log file. I have keep on peeking into the file to monitor the Output. For this I have returned the number of records processed.

Will it affect the Window environment in sense?

If not, then what is the significance of the ExitCode of applications.

Thanks,
Fazal
Posted

It probably won't effect anything.

It is a legacy from the days of DOS: all programs returned an int. Zero was OK, any other value was an error code. Batch programs could then test return codes and decide what processing to do as a result.

When Windows was first developed, it was a Graphical shell on top of DOS, and so it's applications inherited the error code return.

You can access a return code (it is shown in the output pane of VS when you debug a program) when you start a process using the System.Diagnostics.Process class.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Mar-11 15:33pm    
You're late this time... :-)
--SA
The significance of ExitCode is very limited these days. It was mostly designed for console applications for utilities treated in functionality as a single function calls: command line string in output, return value in ExitCode, text output to console via stdout and stderr — a function side effect. Most typical purpose is to return success/error with error code. Batch files (or shell script files) could checkup the error status and use it in some if branches of the batch script code.

It can be used anywhere (windowed applications, too) and has not other effect whatsoever. When you create a process using CreateProcessEx or Process.Create one can preserve the process handle, join the child process (wait until it is complete) and than as the process handle about the ExitCode. The obtained value could be used for the same purposes as those I described above.

I would not say it has no serious applications. (A relatively popular use is making dirty build scripts using some non-standard tools, but I consider this activity as very dirty, nearly a crime — after we got very robust MSBuild utility which allows to integrate anything at all very smoothly based on the very well documented technology.)

—SA
 
Share this answer
 
v3
Comments
Fazlur Rehman 10-Mar-11 15:27pm    
Thanks SAKryukov for your inputs.

This is a small program which does not need much attention. If the ExitCode does not matter for the OS, then I need not bother whatever I return.

I can continue using it.
Thanks.
Fazal
Sergey Alexandrovich Kryukov 10-Mar-11 15:33pm    
You got it.
Thank you for accepting my Answer.
Good luck,
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900