|
I am going to write a C# 2010 application as a console application to start with. Eventually I will change the application to compile as a windows application so I do not get the dos pop windows. When this application goes into production, it will be executed by a windows scheduler. My question is the best way to pass parameters to this application.
Thus can you show me the following:
1. Code on how to accept values from parameters?
2. When the application runs as an executable, can you show me in code how to pass the values to this executable?
|
|
|
|
|
How to access command line parameters[^]. To execute a program with parameters you use a command line of the form:
program_name parameter1 parameter2 "a string parameter with spaces" parametr4 ...
|
|
|
|
|
There are several articles on here regarding parsing command line parameters. Here's one of the more recent ones:
Implementing command execution in a console application[^]
However, I caution you against expecting a Scheduled Task to be able to run a Windows application or anything that needs user interaction.
|
|
|
|
|
I would suggest that you are also likely to need a way to report on failures. So you might want to investigate that as well.
|
|
|
|
|
I see the others have you given you plenty to read regarding the parsing of parameters, so I will just add that it would be best to do ONLY the parsing of parameters and possibly writing of the help text in the Console application and put all actual program logic in a dll. That way you can plug any interface you want into your app: console window, windows UI, WPF, Web Service or whatever.
|
|
|
|