Skip to content

Display resolution shortcuts

Matt Jernigan edited this page Mar 5, 2016 · 7 revisions

Some Windows games will give you the best full-screen results if you change your display resolution to match the original specs for the game. This can be a clickalicious task to change it just to play a quick game and then have to change it back again. Here are a few options to speed it up and/or automate it.

Application Compatibility Setting for 640 x 480

Obviously, this is only if you want to run at 640 x 480:

  • Right click the application EXE file
  • Select Properties
  • Select the Compatibility tab
    • Run in 640 x 480m screen resolution

Note: 8-bit and 16-bit color depth can also be forced here as well.

MultiRes in the System Tray

MultiRes is a free utility for quick access to many display resolutions from the system tray. See their website for more details.

MultiRes in a Batch File

MultiRes can also be called from a batch/command file to both set a specified resolution before a game and to restore the original resolution after a game. For example:

SOMEGAME-1024x768.bat
@echo You can find MultiRes at www.entechtaiwan.com/util/multires.shtm
@echo.
"%ProgramFiles(x86)%\MultiRes\MultiRes.exe" /1024,768 /exit
SOMEGAME.EXE
"%ProgramFiles(x86)%\MultiRes\MultiRes.exe" /restore /exit

Color depth and refresh rate can also be set with a third and fourth number after the width and height. Multiple monitors can be set different ways. The /exit parameter is to avoid loading the system tray tool, if it is desired to keep it unloaded. See their website for more details.

Call a PowerShell Script from a Batch File

PowerShell 1.0 was built into Windows Vista. PowerShell 2.0 was built into Windows 7 and is also available for XP SP3 and Vista. Thus, a PowerShell script is a good option for setting resolution without "installing" any software such as MultiRes.

This solution was written by Andy Schneider and is found here. You can take the heart of his function and put it into a script file:

SetRes.ps1
<#

From a script found here:
blogs.technet.com/b/heyscriptingguy/archive/2010/07/07/hey-scripting-guy-how-can-i-change-my-desktop-monitor-resolution-via-windows-powershell.aspx

    .Synopsis 
        Sets the Screen Resolution of the primary monitor 
    .Description 
        Uses Pinvoke and ChangeDisplaySettings Win32API to make the change 
    .Example 
        Set-ScreenResolution -Width 1024 -Height 768         
    #> 
param ( 
[Parameter(Mandatory=$true, 
           Position = 0)] 
[int] 
$Width, 
 
[Parameter(Mandatory=$true, 
           Position = 1)] 
[int] 
$Height 
) 
 
$pinvokeCode = @" 
 
using System; 
using System.Runtime.InteropServices; 
 
namespace Resolution 
{ 
 
    [StructLayout(LayoutKind.Sequential)] 
    public struct DEVMODE1 
    { 
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] 
        public string dmDeviceName; 
        public short dmSpecVersion; 
        public short dmDriverVersion; 
        public short dmSize; 
        public short dmDriverExtra; 
        public int dmFields; 
 
        public short dmOrientation; 
        public short dmPaperSize; 
        public short dmPaperLength; 
        public short dmPaperWidth; 
 
        public short dmScale; 
        public short dmCopies; 
        public short dmDefaultSource; 
        public short dmPrintQuality; 
        public short dmColor; 
        public short dmDuplex; 
        public short dmYResolution; 
        public short dmTTOption; 
        public short dmCollate; 
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] 
        public string dmFormName; 
        public short dmLogPixels; 
        public short dmBitsPerPel; 
        public int dmPelsWidth; 
        public int dmPelsHeight; 
 
        public int dmDisplayFlags; 
        public int dmDisplayFrequency; 
 
        public int dmICMMethod; 
        public int dmICMIntent; 
        public int dmMediaType; 
        public int dmDitherType; 
        public int dmReserved1; 
        public int dmReserved2; 
 
        public int dmPanningWidth; 
        public int dmPanningHeight; 
    }; 
 
 
 
    class User_32 
    { 
        [DllImport("user32.dll")] 
        public static extern int EnumDisplaySettings(string deviceName, int modeNum, ref DEVMODE1 devMode); 
        [DllImport("user32.dll")] 
        public static extern int ChangeDisplaySettings(ref DEVMODE1 devMode, int flags); 
 
        public const int ENUM_CURRENT_SETTINGS = -1; 
        public const int CDS_UPDATEREGISTRY = 0x01; 
        public const int CDS_TEST = 0x02; 
        public const int DISP_CHANGE_SUCCESSFUL = 0; 
        public const int DISP_CHANGE_RESTART = 1; 
        public const int DISP_CHANGE_FAILED = -1; 
    } 
 
 
 
    public class PrmaryScreenResolution 
    { 
        static public string ChangeResolution(int width, int height) 
        { 
 
            DEVMODE1 dm = GetDevMode1(); 
 
            if (0 != User_32.EnumDisplaySettings(null, User_32.ENUM_CURRENT_SETTINGS, ref dm)) 
            { 
 
                dm.dmPelsWidth = width; 
                dm.dmPelsHeight = height; 
 
                int iRet = User_32.ChangeDisplaySettings(ref dm, User_32.CDS_TEST); 
 
                if (iRet == User_32.DISP_CHANGE_FAILED) 
                { 
                    return "Unable To Process Your Request. Sorry For This Inconvenience."; 
                } 
                else 
                { 
                    iRet = User_32.ChangeDisplaySettings(ref dm, User_32.CDS_UPDATEREGISTRY); 
                    switch (iRet) 
                    { 
                        case User_32.DISP_CHANGE_SUCCESSFUL: 
                            { 
                                return "Success"; 
                            } 
                        case User_32.DISP_CHANGE_RESTART: 
                            { 
                                return "You Need To Reboot For The Change To Happen.\n If You Feel Any Problem After Rebooting Your Machine\nThen Try To Change Resolution In Safe Mode."; 
                            } 
                        default: 
                            { 
                                return "Failed To Change The Resolution"; 
                            } 
                    } 
 
                } 
 
 
            } 
            else 
            { 
                return "Failed To Change The Resolution."; 
            } 
        } 
 
        private static DEVMODE1 GetDevMode1() 
        { 
            DEVMODE1 dm = new DEVMODE1(); 
            dm.dmDeviceName = new String(new char[32]); 
            dm.dmFormName = new String(new char[32]); 
            dm.dmSize = (short)Marshal.SizeOf(dm); 
            return dm; 
        } 
    } 
} 
 
"@ 
 
Add-Type $pinvokeCode -ErrorAction SilentlyContinue 
[Resolution.PrmaryScreenResolution]::ChangeResolution($width,$height) 

You can then call this script from a batch or command file (the following assumes SetRes.ps1 is in the same folder as the calling batch file):

SOMEGAME-1024x768.bat
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "%CD%\SetRes.ps1" 1024 768
SOMEGAME.EXE
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "%CD%\SetRes.ps1" 1366 768

The caveats with this script versus MultiRes is that it cannot set color bit depth, refresh rate, specify which monitor (I haven't tested it with multiple monitors yet but I would assume it sets monitor 1), or restore the original setting. Color depth can be set to 8-bit or 16-bit as noted at the top of this topic with the application compatibility setting. There is no immediate solution to refresh rate and monitor selection (although this script looks like it could be expanded to include dmDisplayResolution easily enough). The original display settings can be restored with some more creative batch work such as writing them to a temp file (like MultiRes does) like so:

SOMEGAME-1024x768.bat
PowerShell.exe -NoProfile ^
  (Get-WmiObject -Class Win32_VideoController).CurrentHorizontalResolution.ToString() ^
  + \" \" + ^
  (Get-WmiObject -Class Win32_VideoController).CurrentVerticalResolution.ToString() ^
  > "%TEMP%\SetResCurrentRes.txt"
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "%CD%\SetRes.ps1" 1024 768
SOMEGAME.EXE
set /p RestoreRes= < "%TEMP%\SetResCurrentRes.txt"
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "%CD%\SetRes.ps1" %RestoreRes%
set RestoreRes=
del "%TEMP%\SetResCurrentRes.txt"

From here it's not hard to go crazy, add some parameters, and build a reusable tool like MultiRes... but I'm trying to keep these installs modular and independent so I'll stop here, for now.