Guest User

Change monitor timeout - With comments

a guest
Jan 26th, 2014
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. REM **REFERS TO THE ABOVE** Using @echo off will prevent commands from
  3. REM **REFERS TO THE ABOVE** printing to the terminal
  4. REM **REFERS TO THE ABOVE** Only the command results will be printed
  5. REM.
  6. REM.
  7. REM "Setlocal" localizes all variables set within this script.
  8. REM This means that when this script exits any variables that have been set
  9. REM using the "set" command will not be remembered.
  10. SETLOCAL
  11.  
  12. REM Sets the title on the title bar of the command prompt window
  13. title Movie Mode
  14. REM.
  15. REM Sets the color of the window and the text within the window.
  16. REM Use color /? for more details
  17. color 53
  18. REM.
  19. REM Echo prints to text in the command prompt window
  20. Echo Do you want to activate movie mode or deactivate movie mode (a or d)?
  21. REM ":ask" is a label used with "goto" to navigate the script
  22. :ask
  23. REM.
  24. REM "Set" is used to set variables within the script
  25. REM In this case it is setting "MON" to nothing to prevent any previous
  26. REM values from remaining
  27. set MON=
  28. REM.
  29. REM "Set /P" will prompt the user for input
  30. REM This will set the variable to the users input after a RETURN
  31. set /P MON=What will it be (a or d)? %=%
  32. REM.
  33. REM "IF /I" will compare "%MON%" (which the user set in the previous
  34. REM line) to "a" and "d"
  35. REM The "I" switch in "IF /I" tells the IF command to ignore cAsE
  36. REM The "goto" command will navigate to the specified label if the
  37. REM statement was true
  38. If /I "%MON%"=="a" goto activate
  39. If /I "%MON%"=="d" goto deactivate
  40. REM.
  41. REM This goto command will only be executed when %MON% is not equal to
  42. REM "A,a,D,d" and will navigate back to the :ask label above
  43. goto ask
  44. REM.
  45.  
  46. REM Label :Activate is executed only if the user entered A or a
  47. :Activate
  48. REM.
  49. echo Setting monitors to never sleep
  50. REM Uses the powercfg command to change the monitor timeout in the Windows
  51. REM power scheme
  52. REM A value of 0 will force the monitors never to sleep
  53. powercfg /Change /monitor-timeout-ac 0
  54. REM.
  55. goto end
  56. REM Label :Activate is executed only if the user entered D or d
  57. :Deactivate
  58. REM.
  59. echo Setting monitors to sleep after 15 minutes
  60. powercfg /Change /monitor-timeout-ac 15
  61. REM Label :end represents the end of the script
  62. :end
  63. REM.
  64. echo Done! Press any key to exit...
  65. REM The "pause" command is used to wait for the user to press a key
  66. REM ">" redirects the standard output of the "pause" command so that it is
  67. REM not seen. For more information on redirection see
  68. REM http://www.robvanderwoude.com/redirection.php
  69. pause>nul
  70.  
  71. REM This is all pretty basic batch scripting and was all written in a
  72. REM hurry and could really be improved in so many ways.
  73. REM.
  74. REM.
  75. REM For /u/save_the_rocks
Advertisement
Add Comment
Please, Sign In to add comment