views:

343

answers:

2

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 environment capable of user-interaction (e.g. Command Prompt or PowerShell)?

+4  A: 

I haven't tested it, but Environment.UserInteractive looks promising.

Michael Stum
+7  A: 

Environment.UserInteractive Property

ArsenMkrt