Is there a way for a Console app know whether it has been called from a batch file as opposed to directly at the command prompt?
The reason for asking is to find a way to decide whether to initiate a Console.ReadLine loop or similar to await further input, or whether to exit immediately.
Alternatively, is there a way for a batch file to continue sending input to a Console App that is awaiting further input via ReadLine?
Yes, I know – that’s 2 questions. If anyone comments that there’s an answer to the second question I’ll ask that separately.
The batch file can set an environment variable and you can check that in your console application:
in the batch file:
in your Console Application: