This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

.NET Framework
.NET 2.0+

Setting the Title for Console Applications

The title bar for a console application that is executed from a command prompt generally shows a default title, rather than the name of the console application. This title can be modified by setting a static property of the Console class.

Console Applications

Console applications are useful for simple processes, or for tasks that do not require substantial input from the user. They are often called from a command prompt window by entering the name of the compiled executable and providing any configuration options via command line switches.

When you run a console application from the command prompt, the title of the window that is displayed will generally default to the path and name of the cmd.exe file. You might want to customise this title to show the name of your application instead. To do so, you simply set the value of the Console class's static Title property.

The following code shows an example of the use of the property. Here the title is initially set to a name for the application. When you press Enter, the title is periodically updated to show the status of a for loop. The percentage values are displayed in the title bar and in the task bar, if configured to show application titles. This is useful to provide the user with status information for a console application that is minimised or otherwise hidden from view.

Console.Title = "Example";
Console.WriteLine("Press Enter to do something slowly");

for (int i = 0; i <= 100; i++)
    Console.Title = string.Format("{0}%", i);

Console.Title = "Example";
17 October 2012