Take the 2-minute tour ×

I have a command line program that expects either no parameter or one parameter. If no parameter is supplied it prompts for the parameter with simple code like:

String theParameter = String.Empty;
if (args.Length == 1) theParameter = args[0];
else {
    Console.Write("Please provide theParameter: ");
    theParameter = Console.ReadLine();
Console.WriteLine("Some Output");

Interactively it works as expected:

> myprogram
Please provide theParameter:
{a value provided}
Some Output


> myprogram SomeValue
Some Output


> myprogram SomeValue > results.log
{Some Output in the results.log file)

All work as expected.

Similarly when I use the Windows 7 Task Scheduler with myprogram SomeValue it starts, executes and completes as expected.

However when I use myprogram SomeValue > results.log to redirect STDOUT to a file it starts, runs and never completes. If I manually run the job (by right clicking and running from the Task Scheduler) it throws up a console window with the Please provide the Parameter.

My question is: Why is the Windows Task Scheduler job short-circuiting my parameter being passed to the program if I redirect STDOUT to a file?

share|improve this question
add comment


Your Answer



Browse other questions tagged or ask your own question.