How to Enable Fullscreen for Console Applications in Windows 10 and Windows 11

Mr.Postal 20 Reputation points
2025-01-13T08:46:23.4033333+00:00

It has been observed that Windows 10 and Windows 11 have different behaviors regarding fullscreen for console applications. Currently, a console application does not enter fullscreen mode as it did on Windows 10 with the code i used.

CodeBlock:

class Program
{
    [DllImport("kernel32.dll", ExactSpelling = true)]
    private static extern IntPtr GetConsoleWindow();

    [DllImport("user32.dll")]
    private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

    private const int SW_MAXIMIZE = 3;

    static void Main(string[] args)
    {
        IntPtr handle = GetConsoleWindow();
        ShowWindow(handle, SW_MAXIMIZE);

        Console.WriteLine("This is a fullscreen console application.");
        Console.ReadLine();
    }
    
}

Is there a way to enable fullscreen for console applications on both versions so it will work no matter if im on Windows 10 or 11? Additionally, could the fact that the console app executes commands instantly instead of line by line impact this functionality? Any guidance on resolving this issue and a few more issues would be greatly appreciated. Thank you.

Edit:

I found out the Console on Windows 11 is different, can i somehow replace it with the older one from windows 10 and test if it works?

it may be bc the newer Console has different features on the UI

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,962 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,041 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,195 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,429 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiale Xue - MSFT 48,686 Reputation points Microsoft Vendor
    2025-01-13T09:38:55.67+00:00

    Hi @Mr.Postal , Welcome to Microsoft Q&A,

    In Windows 11, the default console experience is Windows Terminal instead of the old classic console (ConHost). Windows Terminal does not support direct control of the window size or fullscreen state through ShowWindow, because it is a modern multi-tab terminal.

    One feature of Windows Terminal is that it will set a special environment variable WT_SESSION. You can check this variable to determine if you are running in Windows Terminal.

    If you want to use the classic ConHost console on Windows 11, you can change the system default settings to force the use of the classic console. Of course, this is not convenient to perform on the client machine, you can test it yourself on the development machine.

    For now, at present, Windows Terminal does not support resizing through the console application. For an alternative method, see How to Resize a Console App in C# - Windows Terminal

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.