{"id":15477609,"url":"https://github.com/rickstrahl/setresolution","last_synced_at":"2025-04-13T12:13:29.885Z","repository":{"id":64150377,"uuid":"573756780","full_name":"RickStrahl/SetResolution","owner":"RickStrahl","description":"Quickly set Windows Display Resolution via Command Line","archived":false,"fork":false,"pushed_at":"2025-01-05T09:27:44.000Z","size":1127,"stargazers_count":165,"open_issues_count":3,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-13T12:13:24.438Z","etag":null,"topics":["resolution","windows"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RickStrahl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.MD","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["RickStrahl"]}},"created_at":"2022-12-03T10:36:41.000Z","updated_at":"2025-04-04T02:25:10.000Z","dependencies_parsed_at":"2024-02-07T04:40:06.067Z","dependency_job_id":null,"html_url":"https://github.com/RickStrahl/SetResolution","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickStrahl%2FSetResolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickStrahl%2FSetResolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickStrahl%2FSetResolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickStrahl%2FSetResolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RickStrahl","download_url":"https://codeload.github.com/RickStrahl/SetResolution/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710447,"owners_count":21149191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["resolution","windows"],"created_at":"2024-10-02T04:01:12.940Z","updated_at":"2025-04-13T12:13:29.862Z","avatar_url":"https://github.com/RickStrahl.png","language":"C#","funding_links":["https://github.com/sponsors/RickStrahl"],"categories":[],"sub_categories":[],"readme":"# SetResolution: Set Windows Display Resolution from the Command Line\n\n[![](https://img.shields.io/nuget/v/SetResolution.svg)](https://www.nuget.org/packages/SetResolution/)\n[![](https://img.shields.io/nuget/dt/SetResolution.svg)](https://www.nuget.org/packages/SetResolution/)\n\n![](https://raw.githubusercontent.com/RickStrahl/SetResolution/master/icon-256.png)\n\nThis small command line utility allows you to quickly set Windows Display Resolutions to any of the available display modes available for your active Monitors or virtual display devices. \n\n* Set an explicit Display Resolution\n* Create and use Display Mode Profiles for quick access\n* List all available Display Modes and Monitors\n* Supports multiple Monitors\n* Prompts for confirmation by default to avoid invalid display modes\n* Runs as standalone, single file Windows EXE\n* Can install and run as `dotnet tool` \u003csmall\u003e*(\u003e=0.3 (.NET 9.0), \u003ev0.2 (.NET 8.0), \u003cv0.2 (.NET 6.0))*\u003c/small\u003e\n\n![](https://raw.githubusercontent.com/RickStrahl/SetResolution/master/Assets/SetResolutionMain.png)\n\n## Basic Usage\nMost common usage is via a **pre-defined profile name**:\n\n```powershell\n# Set to a profile named 1080 on default monitor\nSetResolution 1080\n\n# or shortcut version (sr.exe) on Monitor 2\nsr 4k -m2 \n```\n\nWe ship a few default profiles:\n\n* 4k\n* 1080\n* 1440\n* 720\n\nbut you can also edit these or create your own named profiles.\n\nAlternately you can explicitly pick a resolution, frequency, bit rate and Orientation:\n\n```powershell\nsr SET -w 2560 -h 1600 -f 60 -b 32 -o 0 \n```\n*Frequency, BitRate and Orientation are optional*\n\nTo see available resolutions for a specific monitor:\n\n```powershell\n# default list is filtered to current frequency/bitrate/orientation\n# and the `MinResolutionWidth` configuration setting\nsr LIST -m1\n\n# list ALL resolutions/modes\nsr LIST -m1 -la\n```\n\nTo create a new profile:\n\n```powershell\n# Create a new profile\nsr CREATEPROFILE -w 2560 -h 1600 -f 60 -b 32 -o 0 \n\n# List all profiles with their settings\nsr PROFILES\n```\n\n## Installation\nYou can install this tool in a couple of ways (for now).\n\n### Download Single-File EXE Binary\nThis tool is a small, self-contained Console EXE application. For now, you can download the `SetResolution.exe` (or `sr.exe` file directly from here):\n\n[Download SetResolution.exe](https://github.com/RickStrahl/SetResolution/raw/master/Binaries/SetResolution.exe)\n\nI recommend you copy to a folder location that is in your Windows path or add it to your path, so you can run `SetResolution` from any location.\n\n### Install as Dotnet Tool (.NET 9.0 SDK required)\nFor .NET developers the easiest way to install and keep the tool up to date is via Dotnet Tool installation. This requires that the [.NET 9.0 (or later) SDK](https://dotnet.microsoft.com/en-us/download).\n\nYou can install, update and use it with:\n\n```powershell\n# install\ndotnet tool install -g SetResolution\n\nSetResolution 1080 -m2\n\n#update\ndotnet tool update -g SetResolution\n```\n\n### Full Syntax\nTo show available syntax, run `SetResolution.exe` or `sr.exe` without any parameters or `/?` or `HELP`. \nThe help information is as follows:\n\n![Help Screen](https://raw.githubusercontent.com/RickStrahl/SetResolution/master/Assets/HelpScreen.png)\n\n## Multi-Monitor Support\nThis tool supports multiple monitors via the `-m \u003cMonitorNumber\u003e` command line switch. By default the **Main Windows Monitor** monitor is used which corresponds to the **Main Monitor** setting configured in the Windows Display settings.\n\nBoth the `SET`, `PROFILE` and `LIST` commands support the `-m` switch to specify the monitor that the command applies to. Creating a new profile does not specify a monitor.\n\nThe `-m` switch uses a numbering scheme from 1-n, with monitor numbers identified in the `LIST` command. The numbers also reflect the same value you see in the Windows Display Settings dialog.\n\n## List Available Monitors and Display Modes\nYou can use the `LIST` command to show available Monitors and Display Modes as well as the currently selected monitor and display mode. The display modes available are specific for the Monitor/Video Driver combination that is active.\n\nIf you don't specify the `-m` switch which selects a monitor, the **Windows Main Monitor** is used. The list of Display Modes is always specific to the selected monitor. You can explicitly select a monitor via the `-m` switch. \n\nThe selected monitor and display mode are highlighted in the list (green and *).\n\n![](https://raw.githubusercontent.com/RickStrahl/SetResolution/master/Assets/ListDisplay.png)\n\n```powershell\nsr LIST -m1\n```\nThis shows a list of display modes available. By default the list only shows:\n\n* Sizes with the Width \u003e 800 pixels\n* Frequencies that match the current display frequency\n* Orientation that match the current orientation\n\nThis list is similar to the list you see in the Windows Display Resolution drop down list.\n\nIf you want to see `all display modes` available for your monitor/video driver combination use the `-la` command line switch:\n\n```powershell\nsr LIST -m1 -la\n```\n\nThe list displays the selected monitor and display mode for this command in green and with the `*` at the end.\n\nThis displays all displays modes for all sizes, orientations and frequencies. This list tends to very large with many duplicate and overlapping values. However it can be useful to match an exact display mode.\n\nUse these display modes when you create new Profiles and ensure your Profile matches the Display Modes that are supported.\n\n## Profiles\nProfiles are 'shortcuts' to a specific set of saved Display Settings with a name that you can access simply by specifying the profile name:\n\n```powershell\nsr \u003cprofileName\u003e  -m1\n```\nProfiles are the preferred way to switch resolutions as they give you quick access via a single profile name string, instead of having to specify all the settings individually. The `-m1` switch specifies the monitor to apply to - if not specified the Main Windows Monitor is used.\n\nA Profile stores the following values:\n\n* Height and Width\n* Monitor Frequency (60)\n* Color Bit Size  (32)\n* Orientation (0)\n\n\u003csmall\u003e*values in parenthesis are optional default values if not specified*\u003c/small\u003e\n\n\u003e ##### Profiles do not store Monitor numbers\n\u003e If you need to apply to a specific monitor make sure you add the `-m` switch to explicit specify the specific monitor you want to apply the profile to.\n\n ### Create a new Profile\nYou can create a profile with:\n\n```powershell\nSetResolution CREATEPROFILE -p \u003cprofileName\u003e -w 1280 -h 768 -f 59\n```\n#### Manually Edit SetResolution.xml\nProfiles are stored in `SetResolution.xml` in the same folder as the .exe, so you can manually edit the XML file to add or edit profiles. In order to remove profiles you have to edit the `SetResolution.xml` file and remove the entry.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cSetResolution xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\u003e\n   \u003cProfiles\u003e\n      \u003cDisplayProfile\u003e\n         \u003cName\u003e1080\u003c/Name\u003e\n         \u003cWidth\u003e1920\u003c/Width\u003e\n         \u003cHeight\u003e1080\u003c/Height\u003e\n         \u003cFrequency\u003e60\u003c/Frequency\u003e\n         \u003cBitSize\u003e32\u003c/BitSize\u003e\n         \u003cOrientation\u003eDefault\u003c/Orientation\u003e\n      \u003c/DisplayProfile\u003e\n      \u003cDisplayProfile\u003e\n         \u003cName\u003e4k\u003c/Name\u003e\n         \u003cWidth\u003e3840\u003c/Width\u003e\n         \u003cHeight\u003e2160\u003c/Height\u003e\n         \u003cFrequency\u003e60\u003c/Frequency\u003e\n         \u003cBitSize\u003e32\u003c/BitSize\u003e\n         \u003cOrientation\u003eDefault\u003c/Orientation\u003e\n      \u003c/DisplayProfile\u003e\n      \u003cDisplayProfile\u003e\n         \u003cName\u003e1440\u003c/Name\u003e\n         \u003cWidth\u003e2560\u003c/Width\u003e\n         \u003cHeight\u003e1440\u003c/Height\u003e\n         \u003cFrequency\u003e60\u003c/Frequency\u003e\n         \u003cBitSize\u003e32\u003c/BitSize\u003e\n         \u003cOrientation\u003eDefault\u003c/Orientation\u003e\n      \u003c/DisplayProfile\u003e\n      \u003cDisplayProfile\u003e\n         \u003cName\u003e720\u003c/Name\u003e\n         \u003cWidth\u003e1280\u003c/Width\u003e\n         \u003cHeight\u003e720\u003c/Height\u003e\n         \u003cFrequency\u003e60\u003c/Frequency\u003e\n         \u003cBitSize\u003e32\u003c/BitSize\u003e\n         \u003cOrientation\u003eDefault\u003c/Orientation\u003e\n      \u003c/DisplayProfile\u003e\n   \u003c/Profiles\u003e\n   \u003cMinResolution\u003e1280\u003c/MinResolution\u003e\n\u003c/SetResolution\u003e\n```\n\n\u003e #### XML? Really?\n\u003e Yeah I know XML - but to keep the EXE as a fully self-contained, single EXE file and avoid external dependencies, XML serialization is used since it's built into the core framework runtime.\n\n\u003e #### Write Permissions required for Profile File\n\u003e In order to save a new profile using `CREATEPROFILE` you have to have **Write Permissions in the same folder `SetResolution.exe` or `sr.exe`**. This means that preferrably you'll install this tool into a location that supports writing files. \n\u003e \n\u003e Alternately you can manually edit the file, or give the file itself full read/write access.\n\n\n### Setting a Profile\nOnce a profile has been created you can invoke it.\n\n```powershell\n# Shortcut way - on monitor 2\nSetResolution \u003cprofileName\u003e -m2\n\n# Full syntax - on main monitor (not specified)\nSetResolution SET -p \u003cprofileName\u003e -m1\n```\n\n### Default Profiles\nA number of default profiles are added for common 16:9 resolutions @ 60hz which is most common:\n\n```text\nAvailable Profiles\n------------------\n1080:  1920 x 1080, 32, 60\n4k:  3840 x 2160, 32, 60\n1440:  2560 x 1440, 32, 60\n720:  1280 x 720, 32, 60\n```\n\nThese are loaded on first load of the application and stored in the saved profile file (if writable).\n\n### Profiles File Location: SetResolution.xml\nProfiles are stored on disk in `SetResolution.xml` in the same folder as the `.exe` and you can add and remove additional profiles there or add via the `CREATEPROFILE` action as described above.\n\n\u003e **Note:** If you installed the EXE in a location that has no write access, saving of new Profile entries with `CREATEPROFILE` will fail silently. Either give `SetResolution.xml` read/write access or move the application to a location where you are allowed to write files.\n\n\n## Fark: I set a Resolution that doesn't work. Now what?\nWhile it's really, really difficult to do this, if you somehow managed to accidentally set your monitor into a display mode that isn't supported or just doesn't work with your monitor, it's possible that your screen becomes inaccessible. Because this tool switches the default display settings, once a wrong setting is made the screen simply will be blank and it's not just a simple matter of rebooting as the setting is applied to the Windows settings and persists on a reboot.\n\n\u003e To reset a non-working display setting you have to **boot into Windows Safe Mode** and select another display mode, then reboot. \n\nAs mentioned it should be really difficult to get the monitor/driver into a non-working state because we:\n\n* **Check settings for valid display resolutions**  \nYou can't set a resolution that is not supported by the driver/monitor combo at the time of setting the mode. The only way you can get an invalid resolution is if the driver supports a mode, but for some reason the monitor does not. The list SetResolution retrieves for display modes is filtered by Windows to match driver/monitor combos that are expected to work.\n\n* **Prompt for Confirmation of Mode Change**  \nWe prompt for confirmation after the resolution change and if you don't confirm in 5 seconds the display reverts to the previous mode. This ensures if your screen for some reason goes blank, you will revert back to your last working configuration. While I'm not a fan of confirmation prompts, in this case it's both prudent, and only slightly intrusive as you can simply press a key after submitting the shell command. If it really bugs you you can also run with `-noprompt` which skips the prompt (*not recommended though*).\n\n## Changelog\n\n### 0.3.2\n\n* **Fix Persistance across Reboots by Default**  \nResolution changes previously did not persist in the registry and so when the machine was rebooted the changed setting would not persist and the last saved setting (from Windows) would be used for resulution. Now by default the resolution - if set successfully - is saved and restored on reboot. You can use the `--nopersist` flag to not store the new settings in the registry and revert back to the previous resolution.\n\n* **Fix Setting the Frequency**  \nFrequency changes were ignored in previous versions and they should be properly applied now.\n\n* **Dotnet Tool now uses the .NET 9.0 SDK**  \nWe switched to the .NET 9.0 SDK for the dotnet tool operation for v0.3 which is required for this update. Older SDK versions are supported with older versions of this tool (v0.2.x .NET 8.0 SDK).\n\n## Credits\nThe initial code that manages retrieving and setting display modes is based on this excellent article on C# Corner by [Mohammad Elseheimy](https://www.c-sharpcorner.com/members/mohammad-elsheimy):\n\n* [Changing Display Settings Programmatically](https://www.c-sharpcorner.com/uploadfile/GemingLeader/changing-display-settings-programmatically/)\n\nThis derivative tool adds an easy to use Console front-end and provides for multi-monitor support. **Most of the credit for this tool goes to Mohammad's work!**\n\n## To do\n\nnothing","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickstrahl%2Fsetresolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickstrahl%2Fsetresolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickstrahl%2Fsetresolution/lists"}