Search code examples
windowsbatch-filecmdvbscriptwindows-11

Changing Screen Resolution and Scaling in one Batch file, and Launch a .exe file as well


I wanna set the screen resolution of screen 1 to a predetermined value of 1872 x 1248 then set scaling to 100% then launch a .exe file from a folder, and once the exe is closed revert the screen automatically back to 3240 x 2160 and 200% scaling.

EDIT1:

Batch command to change the resolution of a computer

this one helped me set the resolution and it works fine:

  ChangeScreenResolution.exe /w=1872 /h=1248 /d=0

allFiles.exe

/wait allFiles.exe 
ChangeScreenResolution.exe /w=3240 /h=2160 /d=0 

But I couldn't find any resources on how to set resolution scaling at all, that's the missing bit, I'm fairly sure it can be done, but I don't know how.

How can it be done?

Thanks


Solution

  • So thanks to @Compo I figured out how it can be done:

    https://github.com/imniko/SetDPI

    https://tools.taubenkorb.at/change-screen-resolution/

    And these 2 can do the trick for anyone interested:

    ::This bit changes Screen Resolution of Display1 to 1872 x 1248
    ::ChangeScreenResolution.exe [/w=1872 Horizontal Pixels] [/h=1248 Vertical Pixels] [/d=0 Means Display1]
    ChangeScreenResolution.exe /w=1872 /h=1248 /d=0
    
    
    ::This bit changes this bit changes the scaling for Display1 to 125% 
    :: SetDPI.exe [Display Number 1 - means Display1] [Scaling %]
    SetDPI.exe 1 125
    
    ::This bit starts allFiles.exe and goes on to the next line ONLY AFTER IT'S CLOSED
    allFiles.exe /wait 
    
    ::This bit sets resolution back to original
    ::ChangeScreenResolution.exe [/w=3240 Horizontal Pixels] [/h=2160 Vertical Pixels] [/d=0 Means Display1]
    ChangeScreenResolution.exe /w=3240 /h=2160 /d=0 
    
    ::This bit sets scaling back to original
    :: SetDPI.exe /[Display Number 1 - means Display1] /[Scaling %]
    SetDPI.exe 1 200
    

    Thanks guys, it works like a charm now!