Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for switchres.bat

(view source code of switchres.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version (should be Windows 7 or 8)
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. VER | FINDSTR /R /C:" 6\.[12]\." >NUL || GOTO Syntax
  5.  
  6. :: No command line arguments required
  7. IF NOT "%~1"=="" GOTO Syntax
  8.  
  9. SETLOCAL
  10.  
  11. :: Check if SETRES is available
  12. SETRES.EXE d >NUL 2>&1
  13. IF ERRORLEVEL 1 (
  14. 	ECHO.
  15. 	ECHO This script requires Ian Sharpe's SETRES,
  16. 	ECHO available at http://www.iansharpe.com/setres.php
  17. 	ECHO.
  18. 	SET /P Answer=Do you want to download it now? [y/N] 
  19. 	IF /I "!Answer:~0,1"=="Y" (
  20. 		START "Download" http://www.iansharpe.com/setres.php
  21. 		ECHO.
  22. 		ECHO Install SETRES and try again.
  23. 	) ELSE (
  24. 		ECHO.
  25. 		ECHO Download and install SETRES and try again.
  26. 	)
  27. 	ENDLOCAL
  28. 	GOTO:EOF
  29. )
  30.  
  31. :: Read screen width and height
  32. FOR /F %%A IN ('WMIC.EXE Path Win32_DesktopMonitor Get ScreenHeight^,ScreenWidth /Format:LIST 2^>NUL') DO (>NUL SET %%~A)
  33.  
  34. :: For Netbooks (1024x600) only
  35. SET Netbook=1
  36. IF NOT "%ScreenWidth%"=="1024" SET Netbook=0
  37. IF NOT "%ScreenHeight%"=="600" (
  38. 	IF NOT "%ScreenHeight%"=="768" (
  39. 		SET Netbook=0
  40. 	)
  41. )
  42.  
  43. :: Toggle between 1024x768 and 1024x600
  44. IF %ScreenWidth%x%ScreenHeight%==1024x768 (
  45. 	SETRES.EXE h1024 v600
  46. ) ELSE (
  47. 	IF %ScreenWidth%x%ScreenHeight%==1024x600 (
  48. 		SETRES.EXE h1024 v768
  49. 	) ELSE (
  50. 		SET Netbook=0
  51. 	)
  52. )
  53. IF %Netbook% NEQ 1 (
  54. 	ECHO.
  55. 	ECHO ERROR: This script is hardcoded for use with 1024x600 Netbook screens only.
  56. 	ECHO        Detected screen resolution is %ScreenWidth%x%ScreenHeight%
  57. 	ENDLOCAL
  58. 	GOTO Syntax
  59. )
  60.  
  61. ENDLOCAL
  62. GOTO:EOF
  63.  
  64.  
  65. :Syntax
  66. ECHO.
  67. ECHO SwitchRes.bat,  Version 1.00 for Windows 7 and 8
  68. ECHO Toggle a Netbook's screen resolution from 1024x600 to 1024x768 vv.
  69. ECHO.
  70. ECHO Usage:  SWITCHRES
  71. ECHO.
  72. ECHO Note:   This script requires Ian Sharpe's SETRES, available at
  73. ECHO         http://www.iansharpe.com/setres.php
  74. ECHO         You will be prompted to download it if SETRES cannot be found.
  75. ECHO.
  76. ECHO Written by Rob van der Woude
  77. ECHO http://www.robvanderwoude.com
  78.  
  79. IF "%OS%"=="Windows_NT" EXIT /B 1
  80.  

page last uploaded: 2017-07-06, 12:37