How can a Windows console application written in C# determine whether it is invoked in a non-interactive environment (e.g. from a service or as a scheduled task) or from an
I haven't tested it, but Environment.UserInteractive looks promising.