Guest User

Ailuri Task Wrapper 1.12

a guest
May 4th, 2015
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.20 KB | None | 0 0
  1. @echo off
  2. CLS
  3.  
  4.  
  5. :::::::::
  6. ::This script is used to automatically obtain admin privileges to allow the script to be run without choosing "run as administrator"
  7. :::::::::
  8.  
  9.  
  10. :: checking for admin privileges by attempting NET FILE
  11. :checkPrivileges
  12. NET FILE 1>NUL 2>NUL
  13.  
  14. :: if admin privileges are available, skip the rest of the admin script. If not, begin the escalation script.
  15. if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
  16.  
  17. :getPrivileges
  18. if '%1'=='ELEV' (shift & goto gotPrivileges)
  19. ECHO.
  20. ECHO **************************************
  21. ECHO Attempting to escalate privileges
  22. ECHO **************************************
  23.  
  24. setlocal DisableDelayedExpansion
  25. set "batchPath=%~0"
  26. setlocal EnableDelayedExpansion
  27.  
  28. :: echoing code into a .vbs file located in the temp directory which will get us our admin privileges, then running it
  29. ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
  30. ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
  31. "%temp%\OEgetPrivileges.vbs"
  32. exit /B
  33.  
  34. :gotPrivileges
  35.  
  36. setlocal & pushd .
  37.  
  38.  
  39. :::::::
  40. :: this is where the actual script kicks in
  41. :::::::
  42.  
  43.  
  44. :start
  45.  
  46. :: title of the window
  47. title Ailuri Task Wrapper 1.12
  48. echo.
  49. ECHO =============================
  50. ECHO Running as admin
  51. ECHO =============================
  52.  
  53. :: looking for the task in question and displaying its current state
  54. schtasks /QUERY /TN "Anti spindown"
  55. echo.
  56. echo What would you like to do?
  57. echo.
  58.  
  59. :: using set /p to accept user input
  60. set /p batch=Enter "e" to enable, "d" to disable, "q" to quit, or "r" to refresh:
  61.  
  62. if "%batch%" equ "e" (
  63. goto enable
  64. )
  65.  
  66. if "%batch%" equ "d" (
  67. goto disable
  68. )
  69.  
  70. if "%batch%" equ "q" (
  71. goto end
  72. )
  73.  
  74. if "%batch%" equ "r" (
  75. cls
  76. goto start
  77. )
  78.  
  79. :enable
  80.  
  81. :: enabling the task in question, then waiting for 1 second to allow the task to start before restarting the script
  82. schtasks.exe /CHANGE /TN "Anti spindown" /ENABLE
  83. schtasks.exe /RUN /TN "Anti spindown"
  84. timeout /t 1 > NUL
  85. cls
  86. goto start
  87.  
  88. :disable
  89.  
  90. :: disables the task in question and restarts the script. No need to wait here
  91. schtasks.exe /CHANGE /TN "Anti spindown" /DISABLE
  92. cls
  93. goto start
  94.  
  95. :end
Advertisement
Add Comment
Please, Sign In to add comment