Advertisement
corpnewt

Win 10 Tool.bat

Jul 2nd, 2016
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.99 KB | None | 0 0
  1. :::::::::::::::::::::::::::::::::::::::::
  2. :: Automatically check & get admin rights
  3. :::::::::::::::::::::::::::::::::::::::::
  4. @echo off
  5. CLS
  6.  
  7. :checkPrivileges
  8. NET FILE 1>NUL 2>NUL
  9. if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
  10.  
  11. :getPrivileges
  12. if '%1'=='ELEV' (shift & goto gotPrivileges)
  13.  
  14. setlocal DisableDelayedExpansion
  15. set "batchPath=%~0"
  16. setlocal EnableDelayedExpansion
  17. ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
  18. ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
  19. "%temp%\OEgetPrivileges.vbs"
  20. exit /B
  21.  
  22. :gotPrivileges
  23. ::::::::::::::::::::::::::::
  24. ::START
  25. ::::::::::::::::::::::::::::
  26.  
  27. @echo off
  28.  
  29. setlocal enableDelayedExpansion
  30.  
  31. REM I'm annoyed with having to redo a bunch of .reg shit every time I re-install
  32. REM this should consolidate most of that into one process
  33.  
  34. REM Initialize variables:
  35.  
  36. set "useUniversal="
  37. set "useDarkTheme="
  38. set "removeLoginBackground="
  39. set /a windowsTen=0
  40.  
  41. REM We need to get the OS version too, and only allow certain things on their
  42. REM respective versions so we don't clutter shit up.
  43. REM
  44. call :getWindowsMajorVersion vers
  45. call :getWindowsVersion winVers
  46.  
  47. if "!vers!"=="" (
  48. cls
  49. echo ### ###
  50. echo # WARNING #
  51. echo ### ###
  52. echo.
  53. echo Invalid Windows version -
  54. echo press any key to quit.
  55. echo.
  56. pause > nul
  57. exit /b
  58. )
  59.  
  60. if !vers! GEQ 10 set /a windowsTen=1
  61.  
  62. :main
  63. cls
  64. echo ### ###
  65. echo # Win10 Tool - by CorpNewt #
  66. echo ### ###
  67. echo [Windows !winVers!]
  68. echo.
  69.  
  70. REM Here's where we check our reg status - and update
  71. REM our menus accordingly.
  72.  
  73. REM First - let's check for Universal Time
  74. for /f "tokens=3*" %%i in ('reg.exe query "HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" /v "RealTimeIsUniversal" 2^> nul') do (
  75. if NOT "%%i"=="" (
  76. set useUniversal=%%i
  77. )
  78. )
  79. if /i "!useUniversal:~-1,1!"=="1" (
  80. REM We are using Universal Time
  81. echo 1. [DISABLE] Universal Time
  82. ) else (
  83. echo 1. [ENABLE] Universal Time
  84. )
  85.  
  86. REM Now we see if we're on Windows 10 or not
  87. if !vers! LSS 10 (
  88. echo #. [N/A] Dark Theme [Windows 10 ONLY]
  89. echo #. [N/A] Login BG Solid Color [Windows 10 ONLY]
  90. ) else (
  91. REM Let's check for Dark Theme
  92. for /f "tokens=3*" %%i in ('reg.exe query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v "AppsUseLightTheme" 2^> nul') do (
  93. if NOT "%%i"=="" (
  94. set useDarkTheme=%%i
  95. )
  96. )
  97. if /i "!useDarkTheme:~-1,1!"=="0" (
  98. REM We are using Dark Theme
  99. echo 2. [DISABLE] Dark Theme
  100. ) else (
  101. echo 2. [ENABLE] Dark Theme
  102. )
  103.  
  104. REM Let's check for Login Background
  105. for /f "tokens=3*" %%i in ('reg.exe query "HKLM\SOFTWARE\Policies\Microsoft\Windows\System" /v "DisableLogonBackgroundImage" 2^> nul') do (
  106. if NOT "%%i"=="" (
  107. set removeLoginBackground=%%i
  108. )
  109. )
  110. if /i "!removeLoginBackground:~-1,1!"=="1" (
  111. REM We are using Login Background
  112. echo 3. [DISABLE] Login BG Solid Color
  113. ) else (
  114. echo 3. [ENABLE] Login BG Solid Color
  115. )
  116. )
  117. echo.
  118. echo Q. Quit
  119. echo.
  120. set /p "menu=Please select an option to [DISABLE]/[ENABLE]: "
  121.  
  122. if "!menu!"=="" goto main
  123. if /i "!menu!"=="q" exit /b
  124.  
  125. REM Options independent of Windows version
  126. if "!menu!"=="1" goto switchUniversalTime
  127.  
  128. REM Options DEPENDENT on Windows version 10+
  129. if !vers! GEQ 10 (
  130. if "!menu!"=="2" goto switchDarkTheme
  131. if "!menu!"=="3" goto switchLoginBackground
  132. )
  133. goto main
  134.  
  135. :switchUniversalTime
  136. cls
  137. echo ### ###
  138. echo # Win10 Tool - by CorpNewt #
  139. echo ### ###
  140. echo [Windows !winVers!]
  141. echo.
  142. if /i "!useUniversal:~-1,1!"=="1" (
  143. echo [DISABLING] Universal Time
  144. set "useUniversal=0"
  145. ) else (
  146. echo [ENABLING] Universal Time
  147. set "useUniversal=1"
  148. )
  149. call :writeReg "HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" "RealTimeIsUniversal" "REG_DWORD" "!useUniversal!"
  150. goto main
  151.  
  152. :switchDarkTheme
  153. cls
  154. echo ### ###
  155. echo # Win10 Tool - by CorpNewt #
  156. echo ### ###
  157. echo [Windows !winVers!]
  158. echo.
  159. if /i "!useDarkTheme:~-1,1!"=="0" (
  160. echo [DISABLING] Dark Theme
  161. set "useDarkTheme=1"
  162. ) else (
  163. echo [ENABLING] Dark Theme
  164. set "useDarkTheme=0"
  165. )
  166. call :writeReg "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" "AppsUseLightTheme" "REG_DWORD" "!useDarkTheme!"
  167. goto main
  168.  
  169. :switchLoginBackground
  170. cls
  171. echo ### ###
  172. echo # Win10 Tool - by CorpNewt #
  173. echo ### ###
  174. echo [Windows !winVers!]
  175. echo.
  176. if /i "!removeLoginBackground:~-1,1!"=="1" (
  177. echo [DISABLING] Login BG Solid Color
  178. set "removeLoginBackground=0"
  179. ) else (
  180. echo [ENABLING] Login BG Solid Color
  181. set "removeLoginBackground=1"
  182. )
  183. call :writeReg "HKLM\SOFTWARE\Policies\Microsoft\Windows\System" "DisableLogonBackgroundImage" "REG_DWORD" "!removeLoginBackground!"
  184. goto main
  185.  
  186. :writeReg <location> <variableName> <variableType> <value>
  187. echo.
  188. echo %~1
  189. echo ----^> %~2 = %~4
  190. echo.
  191. REG ADD "%~1" /V %~2 /T %~3 /D %~4 /F
  192. echo.
  193. echo Done.
  194. echo.
  195. timeout 5 > nul
  196. goto :EOF
  197.  
  198. pause
  199.  
  200.  
  201. REM ###############################################
  202. REM ### Helper Methods ###
  203. REM ###############################################
  204.  
  205. :getWindowsVersion <result>
  206. for /f "tokens=2 delims=[]" %%x in ('ver') do set WINVER=%%x
  207. set %~1=%WINVER:Version =%
  208. goto :EOF
  209.  
  210. :getWindowsMajorVersion <result>
  211. for /f "tokens=2 delims=[]" %%x in ('ver') do set WINVER=%%x
  212. set WINVER=%WINVER:Version =%
  213. for /f "tokens=1,2,3* delims=." %%a in ("!WINVER!") do set %~1=%%a
  214. goto :EOF
  215.  
  216. :getWindowsMinorVersion <result>
  217. for /f "tokens=2 delims=[]" %%x in ('ver') do set WINVER=%%x
  218. set WINVER=%WINVER:Version =%
  219. for /f "tokens=1,2,3* delims=." %%a in ("!WINVER!") do set %~1=%%b
  220. goto :EOF
  221.  
  222. :getWindowsBuildVersion <result>
  223. for /f "tokens=2 delims=[]" %%x in ('ver') do set WINVER=%%x
  224. set WINVER=%WINVER:Version =%
  225. for /f "tokens=1,2,3* delims=." %%a in ("!WINVER!") do set %~1=%%c
  226. goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement