Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for scrnres.bat

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

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4.  
  5. :: Check command line arguments
  6. IF "%~3"=="" GOTO Syntax
  7. ECHO.%* | FIND.EXE "?" >NUL && GOTO Syntax
  8. ECHO.%* | FIND.EXE "/" >NUL && GOTO Syntax
  9. SET /A %2 >NUL 2>&1 || GOTO Syntax
  10. SET /A %3 >NUL 2>&1 || GOTO Syntax
  11.  
  12. :: Check if remote PC is on-line, abort if not
  13. PING %~1 2>NUL | FIND "TTL=" >NUL || ( ECHO Remote PC %1 is off-line& GOTO:EOF )
  14.  
  15. :: Change the resolution on the remote PC
  16. PSEXEC -C -I -S \\%1 RESCHANGE.EXE -width=%2 -height=%3 -depth=16
  17. GOTO:EOF
  18.  
  19. :Syntax
  20. :: NT needs brackets to be "escaped" by an escape character
  21. SET Esc=
  22. IF "%OS%"=="Windows_NT" SET Esc=^^
  23. :: Display script name only in help screen, without path or extension
  24. SET Me=%~n0
  25. :: Convert script name to upper case
  26. SET Me=%Me:a=A%
  27. SET Me=%Me:b=B%
  28. SET Me=%Me:c=C%
  29. SET Me=%Me:d=D%
  30. SET Me=%Me:e=E%
  31. SET Me=%Me:f=F%
  32. SET Me=%Me:g=G%
  33. SET Me=%Me:h=H%
  34. SET Me=%Me:i=I%
  35. SET Me=%Me:j=J%
  36. SET Me=%Me:k=K%
  37. SET Me=%Me:l=L%
  38. SET Me=%Me:m=M%
  39. SET Me=%Me:n=N%
  40. SET Me=%Me:o=O%
  41. SET Me=%Me:p=P%
  42. SET Me=%Me:q=Q%
  43. SET Me=%Me:r=R%
  44. SET Me=%Me:s=S%
  45. SET Me=%Me:t=T%
  46. SET Me=%Me:u=U%
  47. SET Me=%Me:v=V%
  48. SET Me=%Me:w=W%
  49. SET Me=%Me:x=X%
  50. SET Me=%Me:y=Y%
  51. SET Me=%Me:z=Z%
  52. :: In Windows 9x, the previous code turns the variable into a mess,
  53. :: so for Windows 9x we'll use the full %0 instead
  54. IF NOT "%OS%"=="Windows_NT" SET Me=%0
  55. ECHO.
  56. ECHO ScrnRes.bat,  Version 1.02 for Windows NT 4 / 2000 / XP / Server 2003
  57. ECHO Modify a remote PC's screen resolution
  58. ECHO.
  59. ECHO Usage:  %Me%   PC_name   H_res   V_res
  60. ECHO.
  61. ECHO Where:  PC_name = remote computer's host name
  62. ECHO         H_res   = required horizontal resolution in pixels (640, 800, 1024)
  63. ECHO         V_res   = required  vertical  resolution in pixels (480, 600,  768)
  64. ECHO.
  65. ECHO Notes:  1. Someone must be logged on to the remote computer while you are
  66. ECHO            changing the resolution!
  67. ECHO         2. This batch file requires PSEXEC from SysInternals' PSTools
  68. ECHO            %Esc%(http://www.sysinternals.com/ntw2k/freeware/pstools.shtml%Esc%),
  69. ECHO            12noon's Resolution Changer %Esc%(http://www.12noon.com/download.htm%Esc%)
  70. ECHO            in the working directory, and administrator access on the remote PC.
  71. ECHO         3. Resolution Changer will ignore unsupported H_res/V_res combinations.
  72. ECHO.
  73. ECHO Written by Rob van der Woude
  74. ECHO http://www.robvanderwoude.com
  75. SET Escape=
  76. SET Me=
  77.  

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