Skip to content

Instantly share code, notes, and snippets.

@ivan
Last active June 24, 2022 07:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivan/8a54c90d54393b6084135a949615aa22 to your computer and use it in GitHub Desktop.
Save ivan/8a54c90d54393b6084135a949615aa22 to your computer and use it in GitHub Desktop.
How to maximize all your vscode windows on startup despite whatever stupid mitigations (?) Windows 10 is applying to prevent too many windows from starting maximized at the same time

This is for people who find that

"window.newWindowDimensions": "maximized",

does not actually work on Windows. Symptoms: some or all vscode windows are not maximized on startup.

The first thing you'll want is

"window.restoreWindows": "preserve",

in your vscode JSON preferences. This will always open the projects you had open last time, even when you start Code to open a single file.

Next you'll need to install AutoHotkey. It is available in Chocolatey.

Write these contents to a file somewhere, e.g. C:\opt\maximize_vscode_windows.ahk:

#NoTrayIcon

WinGet, winList, List, ahk_exe Code.exe
Loop %winList%
{
	item := winList%A_Index%
	WinMaximize, ahk_id %item%
}

Next, in some folder that you have vscode always open on startup, add a .vscode/tasks.json with

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Maximize all vscode windows",
            "type": "shell",
            "command": "C:\\Program Files\\AutoHotkey\\AutoHotkey.exe",
            "args": ["C:\\opt\\maximize_vscode_windows.ahk"],
            "group": "none",
            "presentation": {
                "reveal": "never",
                "panel": "shared"
            },
            "runOptions": {
                "runOn": "folderOpen"
            },
            "problemMatcher": []
        }
    ]
}

You can test this task with the Tasks: Run Task command.

Finally, run the Tasks: Manage Automatic Tasks in Folder command and Allow tasks to run automatically.

You should now be able to experience MAXIMIZED VSCODE WINDOWS ON STARTUP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment