How can you determine how a console application was launched?
How can I tell whether the user launched my console application by double-clicking the EXE (or a shortcut), or whether they already had a command line window open and executed my console app within that session? Fowl Stick this static field in your " Program " class to ensure it runs before any output: static bool StartedFromGui = !Console.IsOutputRedirected && !Console.IsInputRedirected && !Console.IsErrorRedirected && Environment.UserInteractive && Environment.CurrentDirectory == System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) && Console.CursorTop == 0