Script for automating a large assortment of AME related actions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1115 lines
73 KiB

2 years ago
  1. @ECHO OFF
  2. REM ---------------------------START----------------------------
  3. MODE 80, 25
  4. TITLE Central AME Script & COLOR 70
  5. SET "ver=v0.9"
  6. REM Allows for more flexibility with these two variables
  7. FOR /F "delims=" %%d in ('echo "%~dp0"') DO SET "dirPath=%%d"
  8. SET "dirPath=%dirPath:~1,-1%"
  9. FOR /F "delims=" %%e in ('echo "%~f0"') DO SET "scriptPath=%%e"
  10. SET "scriptPath=%scriptPath:~1,-1%"
  11. FOR /F %%A IN ('"prompt $H &echo on &for %%B in (1) do rem"') DO SET BS=%%A
  12. PUSHD "%dirPath%"
  13. CALL :AUX-GETUSERNAME
  14. IF /I "%~1"=="LangSet" GOTO DISPLANG-USERCHECK
  15. IF /I "%~1"=="kbLangSet" GOTO KBLANG-PRESET
  16. IF /I "%~1"=="updateFinished" GOTO AUX-UPDATEFINISHED
  17. :PRE-ADMINCHECK1
  18. NET SESSION > NUL 2>&1
  19. IF %ERRORLEVEL% GTR 0 GOTO PRE-ADMINCHECK2
  20. CALL :AUX-ELEVATIONCHECK
  21. IF /I "%currentUsername%"=="RestartRequired" (
  22. ECHO Running this script after a username change may cause issues^! & ECHO.
  23. CHOICE /C YN /N /M "Run anyways? (Y/N): "
  24. IF %ERRORLEVEL%==1 GOTO HOME-MAINMENU
  25. IF %ERRORLEVEL%==2 EXIT /B 0 )
  26. GOTO HOME-MAINMENU
  27. :PRE-ADMINCHECK2
  28. POWERSHELL "Start-Process '%scriptPath%' -Verb RunAs" > NUL 2>&1
  29. IF %ERRORLEVEL% GTR 0 CHOICE /C YN /N /M "Elevation canceled, run with limited functionality? (Y/N): "
  30. IF %ERRORLEVEL%==1 SET lim=rem & GOTO HOME-MAINMENU
  31. IF %ERRORLEVEL%==2 EXIT /B 0
  32. EXIT /B 0
  33. REM -------------------------START-END--------------------------
  34. REM ------------
  35. REM MENU SECTION
  36. REM ------------
  37. REM ----------------------------MENU----------------------------
  38. :HOME-MAINMENU
  39. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  40. %lim%ECHO [1] Change Username or Password
  41. %lim%ECHO [2] Change Lockscreen Image
  42. ECHO [3] Change Language Settings
  43. %lim%ECHO [4] Elevate User to Administrator
  44. %lim%ECHO [5] Login w^/o Typing Username
  45. ECHO.
  46. ECHO [0] Update Script
  47. %lim%ECHO [E] Extra
  48. ECHO [X] Exit & ECHO. & ECHO __________________________________________________________ & ECHO.
  49. CHOICE /C 123450EX8 /N /M "%BS% Choose a menu option: "
  50. %lim%IF %ERRORLEVEL%==1 GOTO USERPASS-MENU
  51. %lim%IF %ERRORLEVEL%==2 GOTO LOCKSCREEN-GRABIMAGE
  52. IF %ERRORLEVEL%==3 GOTO HOME-LANGUAGE
  53. %lim%IF %ERRORLEVEL%==4 GOTO ELEVATE-MENU
  54. %lim%IF %ERRORLEVEL%==5 GOTO NOUSERNAME-MENU
  55. IF %ERRORLEVEL%==6 GOTO AUX-UPDATE
  56. %lim%IF %ERRORLEVEL%==7 GOTO HOME-EXTRA
  57. IF %ERRORLEVEL%==8 EXIT /B 0
  58. GOTO HOME-MAINMENU
  59. :HOME-EXTRA
  60. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  61. %lim%ECHO [1] Enable Windows Script Host (Legacy)
  62. %lim%ECHO [2] Enable NCSI Active Probing (Legacy)
  63. %lim%ECHO.
  64. ECHO [0] Return to Menu & ECHO [X] Exit & ECHO. & ECHO __________________________________________________________ & ECHO.
  65. CHOICE /C 120X /N /M "%BS% Choose a menu option: "
  66. %lim%IF %ERRORLEVEL%==1 GOTO WSH-MENU
  67. %lim%IF %ERRORLEVEL%==2 GOTO NCSI-MENU
  68. IF %ERRORLEVEL%==3 GOTO HOME-MAINMENU
  69. IF %ERRORLEVEL%==4 EXIT /B 0
  70. GOTO HOME-MAINMENU
  71. :HOME-LANGUAGE
  72. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  73. %lim%ECHO [1] Change Display Language
  74. ECHO [2] Add Keyboard Language
  75. %lim%ECHO [3] Install Language Pack
  76. %lim%ECHO [4] Uninstall Language Pack
  77. ECHO. & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO. & ECHO __________________________________________________________ & ECHO.
  78. CHOICE /C 12340X /N /M "%BS% Choose a menu option: "
  79. %lim%IF %ERRORLEVEL%==1 SET "lpStatus=" & GOTO DISPLANG-MENUP1
  80. IF %ERRORLEVEL%==2 GOTO KBLANG-LANGS
  81. %lim%IF %ERRORLEVEL%==3 SET "lpStatus=added"L & GOTO DISPLANG-MENUP1
  82. %lim%IF %ERRORLEVEL%==4 SET "lpStatus=removed" & GOTO DISPLANG-MENUP1
  83. IF %ERRORLEVEL%==5 GOTO HOME-MAINMENU
  84. IF %ERRORLEVEL%==6 EXIT /B 0
  85. GOTO HOME-LANGUAGE
  86. REM --------------------------MENU-END--------------------------
  87. REM -----------------
  88. REM Primary Functions
  89. REM -----------------
  90. REM --------------------------USERPASS--------------------------
  91. :USERPASS-MENU
  92. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO. & ECHO [1] Change Username & ECHO [2] Change Password & ECHO [3] Change Administrator Password & ECHO. & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO. & ECHO __________________________________________________________ & ECHO.
  93. CHOICE /C 1230X /N /M "%BS% Choose a menu option: "
  94. IF %ERRORLEVEL%==1 GOTO USERPASS-USERNAME
  95. IF %ERRORLEVEL%==2 GOTO USERPASS-PASSWORD
  96. IF %ERRORLEVEL%==3 GOTO USERPASS-ADMINPASSWORD
  97. IF %ERRORLEVEL%==4 GOTO HOME-MAINMENU
  98. IF %ERRORLEVEL%==5 EXIT /B 0
  99. :USERPASS-USERNAME
  100. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO.
  101. SET newUsername=
  102. SET /P newUsername="%BS% Enter the new Username, or enter 'Cancel' to quit: "
  103. IF /I "%newUsername%"=="Cancel" GOTO USERPASS-MENU
  104. IF "%newUsername%"=="" (
  105. ECHO. & ECHO. & ECHO Input cannot be blank. & ECHO __________________________________________________________ & ECHO.
  106. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  107. GOTO USERPASS-MENU )
  108. TIMEOUT /T 1 /NOBREAK > NUL
  109. FOR /F "tokens=3" %%A IN ('WMIC useraccount where "name='%currentUsername%'" rename '%newUsername%'') DO SET "wmicOutput=%%A" > NUL 2>&1
  110. IF "%wmicOutput%"=="0;" SET "currentUsername=%newUsername%" & ECHO. & ECHO Username Changed Successfully & ECHO A restart is recommended.
  111. REM This should only happen if the user changes their username AND closes/re-opens the .cmd before restarting.
  112. IF "%wmicOutput%"=="Available." ECHO. & ECHO You must restart before changing your username again.
  113. IF "%wmicOutput%"=="9;" ECHO. & ECHO Invalid input. & SET "loc=USERPASS-MENU"
  114. ECHO __________________________________________________________ & ECHO.
  115. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  116. GOTO HOME-MAINMENU
  117. :USERPASS-PASSWORD
  118. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Username/Password Changer ^| & ECHO.
  119. SET newPassword=
  120. SET /P newPassword="%BS% Enter the new Password, or enter 'Cancel' to quit: "
  121. IF /I "%newPassword%"=="Cancel" GOTO USERPASS-MENU
  122. IF "%newPassword%"=="" (
  123. ECHO. & ECHO Input cannot be blank. :& ECHO __________________________________________________________ & ECHO.
  124. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  125. GOTO USERPASS-MENU )
  126. TIMEOUT /T 1 /NOBREAK > NUL
  127. NET user "%currentUsername%" "%newPassword%" > NUL 2>&1
  128. IF %ERRORLEVEL% LEQ 0 SET "currentPassword=%newPassword%" & ECHO. & ECHO. & ECHO Password Changed Successfully
  129. REM This should only happen if the user changes their username AND closes/re-opens the .cmd before restarting.
  130. IF %ERRORLEVEL% GTR 0 ECHO. & ECHO. & ECHO. & ECHO You must restart after changing your username. & ECHO.
  131. ECHO __________________________________________________________ & ECHO.
  132. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  133. GOTO HOME-MAINMENU
  134. :USERPASS-ADMINPASSWORD
  135. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Username/Password Changer ^| & ECHO.
  136. SET newPassword=
  137. SET /P newPassword="%BS% Enter the new Password, or enter 'Cancel' to quit: "
  138. IF /I "%newPassword%"=="Cancel" GOTO USERPASS-MENU
  139. IF "%newPassword%"=="" (
  140. ECHO. & ECHO Input cannot be blank. :& ECHO __________________________________________________________ & ECHO.
  141. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  142. GOTO USERPASS-MENU )
  143. TIMEOUT /T 1 /NOBREAK > NUL
  144. NET user "Administrator" "%newPassword%" > NUL 2>&1
  145. IF %ERRORLEVEL% LEQ 0 SET "currentPassword=%newPassword%" & ECHO. & ECHO. & ECHO Admin Password Changed Successfully
  146. REM This should only happen if the user changes their username AND closes/re-opens the .cmd before restarting.
  147. IF %ERRORLEVEL% GTR 0 ECHO. & ECHO. & ECHO. & ECHO Action failed. & ECHO.
  148. ECHO __________________________________________________________ & ECHO.
  149. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  150. GOTO HOME-MAINMENU
  151. REM ------------------------USERPASS-END------------------------
  152. REM -------------------------LOCKSCREEN-------------------------
  153. :LOCKSCREEN-GRABIMAGE
  154. REM Original Author & Co-Author: Logan Darklock, lucid
  155. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO Select your image & ECHO.
  156. DIR %SYSTEMDRIVE%\Users | FINDSTR "%possibleUserDir%" > NUL 2>&1
  157. IF %ERRORLEVEL% LEQ 0 SET "ImgSelDir=\%possibleUserDir%"
  158. SET "IMAGEPATH=" & SET "IMAGEEXT="
  159. SET LSPSComm=POWERSHELL -NoP -C "[System.Reflection.Assembly]::LoadWithPartialName('System.windows.forms')|Out-Null;$OFD = New-Object System.Windows.Forms.OpenFileDialog;$OFD.Multiselect = $True;$OFD.Filter = 'Image Files (*.jpg; *.jpeg; *.png; *.bmp; *.jfif)| *.jpg; *.jpeg; *.png; *.bmp; *.jfif';$OFD.InitialDirectory = '%SYSTEMDRIVE%\Users%ImgSelDir%';$OFD.ShowDialog()|out-null;$OFD.FileNames"
  160. REM Execute PowerShell command and get results in IMAGEPATH and IMAGEEXT variables
  161. FOR /F "delims=" %%I in ('%LSPSComm%') DO SET "IMAGEPATH=%%~I" & SET "IMAGEEXT=%%~xI"
  162. IF "%IMAGEPATH%" =="" (
  163. ECHO. & ECHO You must select an image & ECHO __________________________________________________________ & ECHO.
  164. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  165. GOTO HOME-MAINMENU )
  166. :LOCKSCREEN-DEPLOY
  167. TIMEOUT /T 1 /NOBREAK > NUL
  168. REM Copy wallpaper to the right spot
  169. TAKEOWN /F "%WINDIR%\Web\Screen\img100.jpg">NUL 2>&1 & TAKEOWN /F "%WINDIR%\Te\Web\Screen\img103.png">NUL 2>&1 & TAKEOWN /F "%WINDIR%\Web\Wallpaper\Windows\img0.jpg" > NUL 2>&1
  170. ICACLS "%WINDIR%\Web\Screen\img100.jpg" /reSET>NUL & ICACLS "%WINDIR%\Web\Screen\img103.png" /reSET>NUL & ICACLS "%WINDIR%\Web\Wallpaper\Windows\img0.jpg" /reSET > NUL
  171. COPY "%IMAGEPATH%" "%WINDIR%\Web\Screen\img100.jpg" /y>NUL & COPY "%IMAGEPATH%" "%WINDIR%\Web\Screen\img103.png" /y>NUL & COPY "%IMAGEPATH%" "%WINDIR%\Web\Wallpaper\Windows\img0.jpg" /y > NUL
  172. REM Clear cache
  173. TAKEOWN /R /D Y /F "%PROGRAMDATA%\Microsoft\Windows\SystemData" > NUL
  174. ICACLS "%PROGRAMDATA%\Microsoft\Windows\SystemData" /reSET /t > NUL
  175. FOR /D %%x in ("%PROGRAMDATA%\Microsoft\Windows\SystemData\*") do (
  176. FOR /D %%y in ("%%x\ReadOnly\LockScreen_*") do rd /s /q "%%y" )
  177. ECHO. & ECHO Wallpaper changed successfully & ECHO __________________________________________________________ & ECHO.
  178. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  179. GOTO HOME-MAINMENU
  180. REM -----------------------LOCKSCREEN-END-----------------------
  181. REM -------------------------ELEVATION--------------------------
  182. :ELEVATE-MENU
  183. CLS & ECHO %currentUsername%: %userStatus% & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO. & ECHO [1] Elevate your user & ECHO [2] De-elevate your user & ECHO. & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO. & ECHO __________________________________________________________ & ECHO.
  184. CHOICE /C 120X /N /M "%BS% Choose a menu option: "
  185. IF %ERRORLEVEL%==1 SET "elevMenu=1" & GOTO ELEVATE-ELEVATE
  186. IF %ERRORLEVEL%==2 SET "elevMenu=2" & GOTO ELEVATE-REVOKE
  187. IF %ERRORLEVEL%==3 GOTO HOME-MAINMENU
  188. IF %ERRORLEVEL%==4 EXIT /B 0
  189. :ELEVATE-ELEVATE
  190. SET "cenStr=%currentUsername% is already an Administrator." & CALL :AUX-CENTERTEXT
  191. IF "%userStatus%"=="Elevated" (
  192. CLS & ECHO %currentUsername%: %userStatus% & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO. & ECHO. & ECHO%cenOut% & ECHO __________________________________________________________& ECHO.
  193. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  194. GOTO ELEVATE-MENU )
  195. SET "cenStr=Elevating %currentUsername% to Administrator..." & CALL :AUX-CENTERTEXT
  196. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO%cenOut%
  197. TIMEOUT /T 2 /NOBREAK > NUL
  198. NET localgroup administrators "%currentUsername%" /add > NUL 2>&1
  199. IF %ERRORLEVEL% GTR 0 ECHO. & SET "elevFail=true"
  200. IF %ERRORLEVEL% LEQ 0 SET "userStatus=Elevated"
  201. GOTO ELEVATE-FINISH
  202. :ELEVATE-REVOKE
  203. SET "cenStr=%currentUsername% is not an Administator." & CALL :AUX-CENTERTEXT
  204. IF "%userStatus%"=="Not Elevated" (
  205. CLS & ECHO %currentUsername%: %userStatus% & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO. & ECHO%cenOut% & ECHO __________________________________________________________& ECHO.
  206. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  207. GOTO ELEVATE-MENU )
  208. SET "cenStr=Revoking admin rights for %currentUsername%..." & CALL :AUX-CENTERTEXT
  209. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO%cenOut%
  210. TIMEOUT /T 2 /NOBREAK > NUL 2>&1
  211. NET localgroup administrators "%currentUsername%" /delete > NUL 2>&1
  212. IF %ERRORLEVEL% GTR 0 ECHO. & SET "elevFail=true"
  213. IF %ERRORLEVEL% LEQ 0 SET "userStatus=Not Elevated"
  214. GOTO ELEVATE-FINISH
  215. :ELEVATE-FINISH
  216. IF "%elevFail%"=="true" (
  217. ECHO. & ECHO.& ECHO Action failed. A restart may fix this. & ECHO __________________________________________________________ & ECHO.
  218. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  219. GOTO HOME-MAINMENU )
  220. IF "%elevMenu%"=="1" SET "cenStr=%currentUsername% is now an Administrator"
  221. IF "%elevMenu%"=="2" SET "cenStr=Admin rights have been revoked for %currentUsername%"
  222. CALL :AUX-CENTERTEXT
  223. ECHO. & ECHO. & ECHO%cenOut% & ECHO A restart is needed to take effect. & ECHO __________________________________________________________ & ECHO.
  224. CHOICE /C YN /N /M "%BS% Would you like to restart now? (Y/N): "
  225. IF %ERRORLEVEL%==1 SHUTDOWN -R -T 0 & EXIT 0
  226. IF %ERRORLEVEL%==2 GOTO HOME-MAINMENU
  227. REM -----------------------ELEVATION-END------------------------
  228. REM --------------------------DISPLANG--------------------------
  229. :DISPLANG-MENUP1
  230. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  231. ECHO [1] Arabic (ar-SA) & ECHO [2] Bulgarian (bg-BG) & ECHO [3] Chineese [Simplified] (zh-CN) & ECHO [4] Chineese [Traditional] (zh-TW) & ECHO [5] Croatian (hr-HR) & ECHO [6] Czech (cs-CZ) & ECHO [7] Danish (da-DK) & ECHO.
  232. ECHO [N] Next Page & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO Page 1/6 & ECHO __________________________________________________________ & ECHO.
  233. CHOICE /C 1234567N0X /N /M "%BS% Choose a menu option: "
  234. IF %ERRORLEVEL%==1 SET "langSel=ar-SA" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  235. IF %ERRORLEVEL%==2 SET "langSel=bg-BG" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  236. IF %ERRORLEVEL%==3 SET "langSel=zh-CN" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  237. IF %ERRORLEVEL%==4 SET "langSel=zh-TW" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  238. IF %ERRORLEVEL%==5 SET "langSel=hr-HR" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  239. IF %ERRORLEVEL%==6 SET "langSel=cs-CZ" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  240. IF %ERRORLEVEL%==7 SET "langSel=da-DK" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  241. IF %ERRORLEVEL%==8 GOTO DISPLANG-MENUP2
  242. IF %ERRORLEVEL%==9 GOTO HOME-MAINMENU
  243. IF %ERRORLEVEL%==10 EXIT /B 0
  244. :DISPLANG-MENUP2
  245. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  246. ECHO [1] Dutch (nl-NL) & ECHO [2] English [US] (en-US) & ECHO [3] English [UK] (en-GB) & ECHO [4] Estonian (et-EE) & ECHO [5] Finnish (fi-FI) & ECHO [6] French [Canada] (fr-CA) & ECHO [7] French [France] (fr-FR) & ECHO.
  247. ECHO [N] Next Page & ECHO [P] Previous Page & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO Page 2/6 & ECHO __________________________________________________________ & ECHO.
  248. CHOICE /C 1234567NP0X /N /M "%BS% Choose a menu option: "
  249. IF %ERRORLEVEL%==1 SET "langSel=nl-NL" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  250. IF %ERRORLEVEL%==2 SET "langSel=en-US" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  251. IF %ERRORLEVEL%==3 SET "langSel=en-GB" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  252. IF %ERRORLEVEL%==4 SET "langSel=et-EE" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  253. IF %ERRORLEVEL%==5 SET "langSel=fi-FI" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  254. IF %ERRORLEVEL%==6 SET "langSel=fr-CA" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  255. IF %ERRORLEVEL%==7 SET "langSel=fr-FR" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  256. IF %ERRORLEVEL%==8 GOTO DISPLANG-MENUP3
  257. IF %ERRORLEVEL%==9 GOTO DISPLANG-MENUP1
  258. IF %ERRORLEVEL%==10 GOTO HOME-MAINMENU
  259. IF %ERRORLEVEL%==11 EXIT /B 0
  260. :DISPLANG-MENUP3
  261. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  262. ECHO [1] German (de-DE) & ECHO [2] Greek (el-GR) & ECHO [3] Hebrew (he-IL) & ECHO [4] Hungarian (hu-HU) & ECHO [5] Italian (it-IT) & ECHO [6] Japanese (ja-JP) & ECHO [7] Korean (ko-KR) & ECHO.
  263. ECHO [N] Next Page & ECHO [P] Previous Page & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO Page 3/6 & ECHO __________________________________________________________ & ECHO.
  264. CHOICE /C 1234567NP0X /N /M "%BS% Choose a menu option: "
  265. IF %ERRORLEVEL%==1 SET "langSel=de-DE" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  266. IF %ERRORLEVEL%==2 SET "langSel=el-GR" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  267. IF %ERRORLEVEL%==3 SET "langSel=he-IL" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  268. IF %ERRORLEVEL%==4 SET "langSel=hu-HU" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  269. IF %ERRORLEVEL%==5 SET "langSel=it-IT" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  270. IF %ERRORLEVEL%==6 SET "langSel=ja-JP" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  271. IF %ERRORLEVEL%==7 SET "langSel=ko-KR" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  272. IF %ERRORLEVEL%==8 GOTO DISPLANG-MENUP4
  273. IF %ERRORLEVEL%==9 GOTO DISPLANG-MENUP2
  274. IF %ERRORLEVEL%==10 GOTO HOME-MAINMENU
  275. IF %ERRORLEVEL%==11 EXIT /B 0
  276. :DISPLANG-MENUP4
  277. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  278. ECHO [1] Latvian (lv-LV) & ECHO [2] Lithuanian (lt-LT) & ECHO [3] Norwegian (nb-NO) & ECHO [4] Polish (pl-PL) & ECHO [5] Portugeese [Brazil] (pt-BR) & ECHO [6] Portugeese [Portugal] (pt-PT) & ECHO [7] Romanian (ro-RO) & ECHO.
  279. ECHO [N] Next Page & ECHO [P] Previous Page & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO Page 4/6 & ECHO __________________________________________________________ & ECHO.
  280. CHOICE /C 1234567NP0X /N /M "%BS% Choose a menu option: "
  281. IF %ERRORLEVEL%==1 SET "langSel=lv-LV" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  282. IF %ERRORLEVEL%==2 SET "langSel=lt-LT" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  283. IF %ERRORLEVEL%==3 SET "langSel=nb-NO" & SET "dispDl=2.9" & GOTO DISPLANG-DOWNLOAD
  284. IF %ERRORLEVEL%==4 SET "langSel=pl-PL" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  285. IF %ERRORLEVEL%==5 SET "langSel=pt-BR" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  286. IF %ERRORLEVEL%==6 SET "langSel=pt-PT" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  287. IF %ERRORLEVEL%==7 SET "langSel=ro-RO" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  288. IF %ERRORLEVEL%==8 GOTO DISPLANG-MENUP5
  289. IF %ERRORLEVEL%==9 GOTO DISPLANG-MENUP3
  290. IF %ERRORLEVEL%==10 GOTO HOME-MAINMENU
  291. IF %ERRORLEVEL%==11 EXIT /B 0
  292. :DISPLANG-MENUP5
  293. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  294. ECHO [1] Russian (ru-RU) & ECHO [2] Serbian (sr-Latn-RS) & ECHO [3] Slovak (sk-SK) & ECHO [4] Slovenian (sl-SI) & ECHO [5] Spanish [Mexico] (es-MX) & ECHO [6] Spanish [Spain] (es-ES) & ECHO [7] Swedish (sv-SE) & ECHO.
  295. ECHO [N] Next Page & ECHO [P] Previous Page & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO Page 5/6 & ECHO __________________________________________________________ & ECHO.
  296. CHOICE /C 1234567NP0X /N /M "%BS% Choose a menu option: "
  297. IF %ERRORLEVEL%==1 SET "langSel=ru-RU" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  298. IF %ERRORLEVEL%==2 SET "langSel=sr-Latn-RS" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  299. IF %ERRORLEVEL%==3 SET "langSel=sk-SK" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  300. IF %ERRORLEVEL%==4 SET "langSel=sl-SI" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  301. IF %ERRORLEVEL%==5 SET "langSel=es-MX" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  302. IF %ERRORLEVEL%==6 SET "langSel=es-ES" & SET "dispDl=2.5" & GOTO DISPLANG-DOWNLOAD
  303. IF %ERRORLEVEL%==7 SET "langSel=sv-SE" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  304. IF %ERRORLEVEL%==8 GOTO DISPLANG-MENUP6
  305. IF %ERRORLEVEL%==9 GOTO DISPLANG-MENUP4
  306. IF %ERRORLEVEL%==10 GOTO HOME-MAINMENU
  307. IF %ERRORLEVEL%==11 EXIT /B 0
  308. :DISPLANG-MENUP6
  309. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  310. ECHO [1] Thai (th-TH) & ECHO [2] Turkish (tr-TR) & ECHO [3] Ukrainian (uk-UA) & ECHO.
  311. ECHO [P] Previous Page & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO Page 6/6 & ECHO __________________________________________________________ & ECHO.
  312. CHOICE /C 123P0X /N /M "%BS% Choose a menu option: "
  313. IF %ERRORLEVEL%==1 SET "langSel=th-TH" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  314. IF %ERRORLEVEL%==2 SET "langSel=tr-TR" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  315. IF %ERRORLEVEL%==3 SET "langSel=uk-UA" & SET "dispDl=3.2" & GOTO DISPLANG-DOWNLOAD
  316. IF %ERRORLEVEL%==4 GOTO DISPLANG-MENUP5
  317. IF %ERRORLEVEL%==5 GOTO HOME-MAINMENU
  318. IF %ERRORLEVEL%==6 EXIT /B 0
  319. :DISPLANG-DOWNLOAD
  320. SETLOCAL
  321. REM Check if language pack is already installed
  322. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO.
  323. IF "%lpStatus%"=="removed" GOTO DISPLANG-LPREMOVE
  324. WHERE 7z.exe>NUL 2>&1 && SET "dispSkip0=rem "
  325. WHERE choco.exe>NUL 2>&1 && SET "dispChoco=true"
  326. DISM /Online /Get-Intl /English | FIND "Installed language(s): %langSel%" > NUL 2>&1
  327. IF %ERRORLEVEL% LEQ 0 GOTO DISPLANG-USERCHECK
  328. FOR /F tokens^=2^ delims^=^" %%A IN ('TASKLIST /FI "IMAGENAME eq lpksetup.exe" /NH /FO csv') DO SET lpkStatus=%%A
  329. IF "%lpkStatus%"=="," (
  330. ECHO. & ECHO. & ECHO All instances of lpksetup.exe must be closed. & ECHO __________________________________________________________ & ECHO. & ENDLOCAL & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU )
  331. ECHO A ~%dispDl%GB Language Packs ISO must be downloaded & ECHO.
  332. CHOICE /C YN /N /M "%BS% Continue? (Y/N): "
  333. IF %ERRORLEVEL%==2 ENDLOCAL & GOTO HOME-MAINMENU
  334. PING -n 1 archlinux.org -w 20000 > NUL 2>&1
  335. IF %ERRORLEVEL% GTR 0 (
  336. ECHO. & ECHO. & ECHO An internet connection is required. & ECHO __________________________________________________________ & ECHO. & ENDLOCAL & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU )
  337. FOR /F "tokens=2 delims==" %%A IN ('WMIC logicaldisk where "DeviceID='%~d0'" get FreeSpace /format:value') DO SET freeSpace=%%A
  338. SET "freeSpace=%freeSpace:~0,-10%"
  339. IF "%freeSpace%"=="" SET "freeSpace=1"
  340. IF %freeSpace% LSS 5 (
  341. ECHO. & ECHO. & ECHO Not enough free disk space. & ECHO __________________________________________________________ & ECHO. & ENDLOCAL & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU )
  342. IF EXIST "%dirPath%LangPacks.ISO" DEL /Q "%dirPath%LangPacks.ISO"
  343. IF EXIST "%dirPath%LangPacks" RMDIR /Q /S "%dirPath%LangPacks"
  344. REM If 7zip must be installed, there will not be enough space to display everything in 25 lines (script height) without this line
  345. %dispSkip0%CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^|
  346. ECHO. & ECHO Download Progress
  347. IF "%dispDl%"=="2.5" CURL --range 0-2480000000 -L --progress-bar "https://software-download.microsoft.com/download/pr/19041.1.191206-1406.vb_release_CLIENTLANGPACKDVD_OEM_MULTI.iso" --output "%dirPath%LangPacks.ISO"
  348. IF "%dispDl%"=="2.9" CURL --range 0-2900000000 -L --progress-bar "https://software-download.microsoft.com/download/pr/19041.1.191206-1406.vb_release_CLIENTLANGPACKDVD_OEM_MULTI.iso" --output "%dirPath%LangPacks.ISO"
  349. IF "%dispDl%"=="3.2" CURL --range 0-3230000000 -L --progress-bar "https://software-download.microsoft.com/download/pr/19041.1.191206-1406.vb_release_CLIENTLANGPACKDVD_OEM_MULTI.iso" --output "%dirPath%LangPacks.ISO"
  350. FOR %%A IN ("%dirPath%LangPacks.ISO") DO SET "langISOSize=%%~zA"
  351. IF "%langISOSize"=="" SET "langISOSize=1"
  352. REM Detects size of ISO file, this essentially allows for a simple error detection.
  353. IF %langISOSize% LSS 700000 (
  354. DEL /Q "%dirPath%LangPacks.ISO" > NUL
  355. ENDLOCAL
  356. GOTO AUX-UPDATEFAILED )
  357. :DISPLANG-INSTALL
  358. %dispSkip0%IF NOT "%dispChoco%"=="true" (
  359. %dispSkip0% ECHO. & ECHO. & ECHO 7zip or choclatey must be installed. & ECHO __________________________________________________________ & ECHO. & ENDLOCAL & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU )
  360. %dispSkip0%ECHO. & ECHO Installing 7zip... & choco install -y --force --allow-empty-checksums "7zip" > NUL
  361. 7z e -y -o"%dirPath%LangPacks" "%dirPath%LangPacks.ISO" x64\langpacks\*.cab > NUL 2>&1
  362. ECHO. & ECHO Installing language pack. This might take awhile & ECHO.
  363. FOR /F "tokens=2" %%A IN ('DATE /T') DO SET "dateAfter=%%A"
  364. SET "timeAfter=%TIME:~0,-3%"
  365. LPKSETUP /i %langSel% /p "%dirPath%LangPacks\Microsoft-Windows-Client-Language-Pack_x64_%langSel%.cab" /r > NUL
  366. :lpkInstLogLoop
  367. TIMEOUT /T 1 /NOBREAK > NUL
  368. POWERSHELL -NoP -C "$timeAfter = Get-Date -Date '%dateAfter% %timeAfter%'; Get-WinEvent -FilterHashtable @{Logname='Microsoft-Windows-LanguagePackSetup/Operational';StartTime=$timeAfter}" | FINDSTR "2014 2007" > NUL
  369. IF %ERRORLEVEL% LSS 1 (
  370. %dispSkip0%ECHO Removing 7zip... & choco uninstall 7zip -y --force-dependencies --allow-empty-checksums>NUL & ECHO.
  371. DEL /Q "%dirPath%LangPacks.ISO">NUL & RMDIR /Q /S "%dirPath%LangPacks" & ECHO. & ECHO. & ECHO Action failed. & ECHO __________________________________________________________ & ECHO. & ENDLOCAL & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU
  372. )
  373. POWERSHELL -NoP -C "$timeAfter = Get-Date -Date '%dateAfter% %timeAfter%'; Get-WinEvent -FilterHashtable @{Logname='Microsoft-Windows-LanguagePackSetup/Operational';StartTime=$timeAfter}" | FINDSTR "2000" > NUL
  374. IF %ERRORLEVEL% LSS 1 (
  375. %dispSkip0%ECHO Removing 7zip... & choco uninstall 7zip -y --force-dependencies --allow-empty-checksums>NUL & ECHO.
  376. IF "%lpStatus%"=="added" DEL /Q "%dirPath%LangPacks.ISO">NUL & RMDIR /Q /S "%dirPath%LangPacks" & GOTO DISPLANG-LPCOMPLETE
  377. DEL /Q "%dirPath%LangPacks.ISO">NUL & RMDIR /Q /S "%dirPath%LangPacks" & GOTO DISPLANG-USERCHECK
  378. )
  379. GOTO :lpkInstLogLoop
  380. :DISPLANG-USERCHECK
  381. IF /I "%~1"=="LangSet" WAITFOR /SI Golden>NUL 2>&1 & SET "langSel=%~2" & SET "makeKBDef=%~3" & GOTO DISPLANG-SETLANG
  382. CHOICE /C YN /N /M "%BS% Make default keyboard language? (Y/N): "
  383. IF %ERRORLEVEL%==2 SET "makeKBDef=false"
  384. REM The FOR command creates a new process ID, and thus cannot be used here
  385. POWERSHELL -NoP -C "(Get-WmiObject Win32_Process -Filter ProcessId=$PID).ParentProcessId" > %temp%\CentralAMEProcessID.txt
  386. FOR /F "delims=" %%A IN (%temp%\CentralAMEProcessID.txt) DO SET "scriptPID=%%A" & DEL "%temp%\CentralAMEProcessID.txt"
  387. REM Detects if the script is being run under the currently logged in user. If not it runs a second instance as the current user
  388. FOR /F tokens^=2^ delims^=^" %%A IN ('TASKLIST /FI "PID eq %scriptPID%" /FI "USERNAME eq %currentUsername%" /NH /FO csv') DO SET processRunOut=%%A
  389. IF NOT "%processRunOut%"=="," (
  390. REM If %lim% = rem that means the script is NOT being run as administrator. There's a small chance someone attempts to run it as another non-admin user,
  391. REM this would be problematic as schtasks requires admin privilages.
  392. IF "%lim%"=="rem " ECHO. & ECHO. & ECHO Script must be run as the current user & ECHO or with administrator privilages. & ECHO __________________________________________________________ & ECHO. & ENDLOCAL & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU
  393. SETLOCAL ENABLEDELAYEDEXPANSION
  394. SCHTASKS /CREATE /tn SetDispLang /tr "CMD /C 'START /min '' '%scriptPath%' LangSet %langSel% %makeKBDef%'" /sc ONSTART /ru "%currentUsername%" /it /f > NUL
  395. REM RUNAS will work, however it requires the user to enter a password, and won't accept a blank one. This is a lot more simple and reliable
  396. SCHTASKS /RUN /tn SetDispLang > NUL
  397. WAITFOR Golden /T 10 > NUL 2>&1
  398. IF !ERRORLEVEL! LSS 1 SCHTASKS /DELETE /tn SetDispLang /f>NUL & GOTO DISPLANG-COMPLETE
  399. SCHTASKS /DELETE /tn SetDispLang /f > NUL
  400. ENDLOCAL & ENDLOCAL & ECHO. & ECHO. & ECHO Action failed. & ECHO __________________________________________________________ & ECHO. & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU )
  401. :DISPLANG-SETLANG
  402. ECHO. & ECHO Setting language...
  403. FOR /F "delims= " %%A IN ('POWERSHELL -NoP -C "Get-WinDefaultInputMethodOverride"') DO SET "possibleLangDef=%%A"
  404. IF NOT "%possibleLangDef%"=="" SET "currentLangDef=%possibleLangDef%" & SET "dispSkip1=rem "
  405. %dispSkip1%FOR /F "delims=" %%A IN ('POWERSHELL -NoP -C "(Get-WinUserLanguageList)[0].InputMethodTips"') DO SET "currentLangDef=%%A"
  406. SETLOCAL ENABLEDELAYEDEXPANSION
  407. REM Accounts for zero input methods. Very unlikely scenario
  408. POWERSHELL -NoP -c "(Get-WinUserLanguageList).InputMethodTips" | FINDSTR ":" > NUL 2>&1
  409. IF %ERRORLEVEL% GTR 0 SET "dispSkip2=rem "
  410. %dispSkip2%FOR /F "delims=" %%A IN ('POWERSHELL -NoP -C "(Get-WinUserLanguageList).InputMethodTips"') DO SET "oldInputMethods=!oldInputMethods!;$LangList[0].InputMethodTips.Add('%%A')"
  411. POWERSHELL -NoP -C "Set-WinSystemLocale %langSel%; $LangList = New-WinUserLanguageList %langSel%%oldInputMethods%; Set-WinUserLanguageList $LangList -Force"
  412. REM Clears override
  413. IF "%makeKBDef%"=="" POWERSHELL -NoP -C "Set-WinDefaultInputMethodOverride"
  414. IF "%makeKBDef%"=="false" POWERSHELL -NoP -C "Set-WinDefaultInputMethodOverride "%currentLangDef%""
  415. ENDLOCAL
  416. IF /I "%~1"=="LangSet" EXIT 0
  417. :DISPLANG-COMPLETE
  418. ECHO. & ECHO. & ECHO Display language changed to %langSel% & ECHO A restart is needed to take effect. & ECHO __________________________________________________________ & ECHO.
  419. ENDLOCAL
  420. CHOICE /C YN /N /M "%BS% Would you like to restart now? (Y/N): "
  421. IF %ERRORLEVEL%==1 SHUTDOWN -R -T 0 & EXIT 0
  422. IF %ERRORLEVEL%==2 GOTO HOME-MAINMENU
  423. :DISPLANG-LPCOMPLETE
  424. %dispSkip0%ECHO. & ECHO Removing 7zip... & choco uninstall 7zip.install -y --force > NUL
  425. %dispSkip0%choco uninstall 7zip -y --force > NUL
  426. ECHO. & ECHO. & ECHO LanguagePack %langSel% %lpStatus% successfully & ECHO A restart is recommended. & ECHO __________________________________________________________ & ECHO.
  427. ENDLOCAL
  428. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  429. GOTO HOME-MAINMENU
  430. :DISPLANG-LPREMOVE
  431. SET "dispSkip0=rem "
  432. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO.
  433. FOR /F tokens^=2^ delims^=^" %%A IN ('TASKLIST /FI "IMAGENAME eq lpksetup.exe" /NH /FO csv') DO SET "lpkStatus=%%A"
  434. IF "%lpkStatus%"=="," (
  435. ECHO. & ECHO. & ECHO All instances of lpksetup.exe must be closed. & ECHO __________________________________________________________ & ECHO. & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU )
  436. FOR /F "tokens=2" %%A IN ('DATE /T') DO SET "dateAfter=%%A"
  437. SET "timeAfter=%TIME:~0,-3%"
  438. ECHO Uninstalling %langSel% LanguagePack...
  439. LPKSETUP /u %langSel% /r
  440. :lpkRemLogLoop
  441. TIMEOUT /T 1 /NOBREAK > NUL
  442. POWERSHELL -command "$timeAfter = Get-Date -Date '%dateAfter% %timeAfter%'; Get-WinEvent -FilterHashtable @{Logname='Microsoft-Windows-LanguagePackSetup/Operational';StartTime=$timeAfter}" | FINDSTR "2014 2008" > NUL
  443. IF %ERRORLEVEL% LSS 1 ECHO. & ECHO. & ECHO Action failed. & ECHO __________________________________________________________ & ECHO. & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU
  444. POWERSHELL -command "$timeAfter = Get-Date -Date '%dateAfter% %timeAfter%'; Get-WinEvent -FilterHashtable @{Logname='Microsoft-Windows-LanguagePackSetup/Operational';StartTime=$timeAfter}" | FINDSTR "2001" > NUL
  445. IF %ERRORLEVEL% LSS 1 GOTO DISPLANG-LPCOMPLETE
  446. GOTO lpkRemLogLoop
  447. REM ------------------------DISPLANG-END------------------------
  448. REM ---------------------------KBLANG---------------------------
  449. :KBLANG-LANGS
  450. SETLOCAL ENABLEDELAYEDEXPANSION
  451. FOR /F "tokens=1 delims=:" %%A IN ('FINDSTR /B /N /C:"REM DB-Languages" "%~f0"') DO SET /A dbStartLine=%%A
  452. SET /A count=0
  453. SET "kbSub=false"
  454. FOR /F "usebackq tokens=1, 2, 4, 6, 8, 10, 12, 14 skip=%dbStartLine% delims=|" %%A IN ("%~f0") DO (
  455. IF "%%A"=="REM DB-Corresponding Commands" GOTO KBLANG-CCOMMS
  456. IF "%%B"=="" GOTO KBLANG-CCOMMS
  457. IF NOT "%%B"=="spacer" SET /A count=!count!+1 & SET "lang!count!=%%B"
  458. IF "%%C"=="" GOTO KBLANG-CCOMMS
  459. IF NOT "%%C"=="spacer" SET /A "count=!count!+1" & SET "lang!count!=%%C"
  460. IF "%%D"=="" GOTO KBLANG-CCOMMS
  461. IF NOT "%%D"=="spacer" SET /A "count=!count!+1" & SET "lang!count!=%%D"
  462. IF "%%E"=="" GOTO KBLANG-CCOMMS
  463. IF NOT "%%E"=="spacer" SET /A "count=!count!+1" & SET "lang!count!=%%E"
  464. IF "%%F"=="" GOTO KBLANG-CCOMMS
  465. IF NOT "%%F"=="spacer" SET /A "count=!count!+1" & SET "lang!count!=%%F"
  466. REM Overflow protecton, allows for more than 5 items per DB line
  467. IF NOT "%%G"=="" SET /A "count=!count!+1" & SET "lang!count!=%%G"
  468. IF NOT "%%H"=="" SET /A "count=!count!+1" & SET "lang!count!=%%H"
  469. )
  470. :KBLANG-CCOMMS
  471. FOR /F "tokens=1 delims=:" %%A IN ('FINDSTR /B /N /C:"REM DB-Corresponding Commands" "%~f0"') DO SET /A dbStartLine=%%A
  472. SET /A kbCCommCount=0
  473. FOR /F "usebackq tokens=1, 2, 4, 6, 8, 10, 12, 14 skip=%dbStartLine% delims=|" %%A IN ("%~f0") DO (
  474. IF "%%A"=="REM DB-Submenu Input Methods" GOTO KBLANG-PREMMS
  475. IF "%%B"=="" GOTO KBLANG-PREMMS
  476. IF NOT "%%B"=="spacer" SET /A kbCCommCount=!kbCCommCount!+1 & SET "kbComm!kbCCommCount!=SET kbLangSel=%%B"
  477. IF "%%C"=="" GOTO KBLANG-PREMMS
  478. IF NOT "%%C"=="spacer" SET /A "kbCCommCount=!kbCCommCount!+1" & SET "kbComm!kbCCommCount!=SET kbLangSel=%%C"
  479. IF "%%D"=="" GOTO KBLANG-PREMMS
  480. IF NOT "%%D"=="spacer" SET /A "kbCCommCount=!kbCCommCount!+1" & SET "kbComm!kbCCommCount!=SET kbLangSel=%%D"
  481. IF "%%E"=="" GOTO KBLANG-PREMMS
  482. IF NOT "%%E"=="spacer" SET /A "kbCCommCount=!kbCCommCount!+1" & SET "kbComm!kbCCommCount!=SET kbLangSel=%%E"
  483. IF "%%F"=="" GOTO KBLANG-PREMMS
  484. IF NOT "%%F"=="spacer" SET /A "kbCCommCount=!kbCCommCount!+1" & SET "kbComm!kbCCommCount!=SET kbLangSel=%%F"
  485. REM Overflow protecton, allows for more than 5 items per DB line
  486. IF NOT "%%G"=="" SET /A "count=!count!+1" & SET "lang!count!=SET kbLangSel=%%G"
  487. IF NOT "%%H"=="" SET /A "count=!count!+1" & SET "lang!count!=SET kbLangSel=%%H"
  488. )
  489. :KBLANG-SUBLANGS
  490. SETLOCAL ENABLEDELAYEDEXPANSION
  491. FOR /F "tokens=1 delims=:" %%A IN ('FINDSTR /B /N /C:"REM DB-Submenu Input Methods" "%~f0"') DO SET /A dbStartLine=%%A
  492. SET /A count=0
  493. SET "kbSub=true"
  494. FOR /F "usebackq tokens=1, 2, 4, 6, 8, 10, 12, 14, 16, 18 skip=%dbStartLine% delims=|" %%A IN ("%~f0") DO (
  495. IF "%%A"=="REM DB-SubCorresponding Input Methods" GOTO KBLANG-CCOMMS
  496. IF "%%B"=="%kbLangSel%" (
  497. IF "%%C"=="" GOTO KBLANG-SUBCOMMS
  498. SET /A count=!count!+1 & SET "lang!count!=%%C"
  499. IF "%%D"=="" GOTO KBLANG-SUBCCOMMS
  500. SET /A "count=!count!+1" & SET "lang!count!=%%D"
  501. IF "%%E"=="" GOTO KBLANG-SUBCCOMMS
  502. SET /A "count=!count!+1" & SET "lang!count!=%%E"
  503. IF "%%F"=="" GOTO KBLANG-SUBCCOMMS
  504. SET /A "count=!count!+1" & SET "lang!count!=%%F"
  505. IF "%%G"=="" GOTO KBLANG-SUBCCOMMS
  506. SET /A "count=!count!+1" & SET "lang!count!=%%G"
  507. IF "%%H"=="" GOTO KBLANG-SUBCCOMMS
  508. SET /A "count=!count!+1" & SET "lang!count!=%%H"
  509. IF "%%I"=="" GOTO KBLANG-SUBCCOMMS
  510. SET /A "count=!count!+1" & SET "lang!count!=%%I"
  511. IF "%%J"=="" GOTO KBLANG-SUBCCOMMS
  512. SET /A "count=!count!+1" & SET "lang!count!=%%J"
  513. )
  514. )
  515. :KBLANG-SUBCCOMMS
  516. FOR /F "tokens=1 delims=:" %%A IN ('FINDSTR /B /N /C:"REM DB-SubCorresponding Input Methods" "%~f0"') DO SET /A dbStartLine=%%A
  517. SET /A skbCCommCount=0
  518. FOR /F "usebackq tokens=1, 2, 4, 6, 8, 10, 12, 14, 16, 18 skip=%dbStartLine% delims=|" %%A IN ("%~f0") DO (
  519. IF "%%A"=="REM Marker" GOTO KBLANG-PREMMS
  520. IF "%%B"=="%kbLangSel%" (
  521. IF "%%C"=="" GOTO KBLANG-PREMMS
  522. SET /A skbCCommCount=!skbCCommCount!+1 & SET "kbComm!skbCCommCount!=SET kbLangSel=%%C& GOTO KBLANG-PRESET"
  523. IF "%%D"=="" GOTO KBLANG-PREMMS
  524. SET /A "skbCCommCount=!skbCCommCount!+1" & SET "kbComm!skbCCommCount!=SET kbLangSel=%%D& GOTO KBLANG-PRESET"
  525. IF "%%E"=="" GOTO KBLANG-PREMMS
  526. SET /A "skbCCommCount=!skbCCommCount!+1" & SET "kbComm!skbCCommCount!=SET kbLangSel=%%E& GOTO KBLANG-PRESET"
  527. IF "%%F"=="" GOTO KBLANG-PREMMS
  528. SET /A "skbCCommCount=!skbCCommCount!+1" & SET "kbComm!skbCCommCount!=SET kbLangSel=%%F& GOTO KBLANG-PRESET"
  529. IF "%%G"=="" GOTO KBLANG-PREMMS
  530. SET /A "skbCCommCount=!skbCCommCount!+1" & SET "kbComm!skbCCommCount!=SET kbLangSel=%%G& GOTO KBLANG-PRESET"
  531. IF "%%H"=="" GOTO KBLANG-PREMMS
  532. SET /A "skbCCommCount=!skbCCommCount!+1" & SET "kbComm!skbCCommCount!=SET kbLangSel=%%H& GOTO KBLANG-PRESET"
  533. IF "%%I"=="" GOTO KBLANG-PREMMS
  534. SET /A "skbCCommCount=!skbCCommCount!+1" & SET "kbComm!skbCCommCount!=SET kbLangSel=%%I& GOTO KBLANG-PRESET"
  535. IF "%%J"=="" GOTO KBLANG-PREMMS
  536. SET /A "skbCCommCount=!skbCCommCount!+1" & SET "kbComm!skbCCommCount!=SET kbLangSel=%%J& GOTO KBLANG-PRESET"
  537. )
  538. )
  539. :KBLANG-PREMMS
  540. SET kbLangCount=0
  541. SET /A "kbLangPages=%count%/9"
  542. SET /A "kbLangRemainder=%count%-(%kbLangPages%*9)""
  543. IF "%kbLangRemainder%" GTR "0" SET /A kbLangPages=%kbLangPages%+1
  544. SET kbLangPageLoc=1
  545. :KBLANG-MMS
  546. REM Modular menu system
  547. SET "lELs=9"
  548. IF "%kbSub%"=="true" (SET "kb0Opt=Go Back") ELSE (SET "kb0Opt=Return to Menu")
  549. SET "kbDisablePrev=" & SET "lC10=N" & SET "kbDisableNext=" & SET "lC11=P"
  550. IF "%kbLangPageLoc%" EQU "1" SET "kbDisablePrev=rem " & SET "lC11="
  551. SET "lC1=1" & SET "lC2=2" & SET "lC3=3" & SET "lC4=4" & SET "lC5=5" & SET "lC6=6" & SET "lC7=7" & SET "lC8=8" & SET "lC9=9"
  552. SET "kbLangSkip1=" & SET "kbLangSkip2=" & SET "kbLangSkip3=" & SET "kbLangSkip4=" & SET "kbLangSkip5=" & SET "kbLangSkip6=" & SET "kbLangSkip7=" & SET "kbLangSkip8="
  553. IF "%kbLangPageLoc%"=="%kbLangPages%" (
  554. SET "kbDisableNext=rem " & SET "lC10="
  555. IF "%kbLangRemainder%" GTR "0" (
  556. SET "lR1=1"
  557. SET "lELs=%kbLangRemainder%"
  558. IF NOT "%kbLangRemainder%" GTR "1" (SET "kbLangSkip1=rem ") ELSE (SET "lR2=2")
  559. IF NOT "%kbLangRemainder%" GTR "2" (SET "kbLangSkip2=rem ") ELSE (SET "lR3=3")
  560. IF NOT "%kbLangRemainder%" GTR "3" (SET "kbLangSkip3=rem ") ELSE (SET "lR4=4")
  561. IF NOT "%kbLangRemainder%" GTR "4" (SET "kbLangSkip4=rem ") ELSE (SET "lR5=5")
  562. IF NOT "%kbLangRemainder%" GTR "5" (SET "kbLangSkip5=rem ") ELSE (SET "lR6=6")
  563. IF NOT "%kbLangRemainder%" GTR "6" (SET "kbLangSkip6=rem ") ELSE (SET "lR7=7")
  564. IF NOT "%kbLangRemainder%" GTR "7" (SET "kbLangSkip7=rem ") ELSE (SET "lR8=8")
  565. IF NOT "%kbLangRemainder%" GTR "8" (SET "kbLangSkip8=rem ") ELSE (SET "lR9=9")
  566. SET "lC1=!lR1!" & SET "lC2=!lR2!" & SET "lC3=!lR3!" & SET "lC4=!lR4!" & SET "lC5=!lR5!" & SET "lC6=!lR6!" & SET "lC7=!lR7!" & SET "lC8=!lR8!" & SET "lC9=!lR9!"
  567. )
  568. )
  569. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  570. SET /A "kbLangCount=%kbLangCount%+1"
  571. ECHO [1] !lang%kbLangCount%! & SET "kbCComm1=!kbComm%kbLangCount%!"
  572. %kbLangSkip1%SET /A "kbLangCount=%kbLangCount%+1"
  573. %kbLangSkip1%ECHO [2] !lang%kbLangCount%! & SET "kbCComm2=!kbComm%kbLangCount%!"
  574. %kbLangSkip2%SET /A "kbLangCount=%kbLangCount%+1"
  575. %kbLangSkip2%ECHO [3] !lang%kbLangCount%! & SET "kbCComm3=!kbComm%kbLangCount%!"
  576. %kbLangSkip3%SET /A "kbLangCount=%kbLangCount%+1"
  577. %kbLangSkip3%ECHO [4] !lang%kbLangCount%! & SET "kbCComm4=!kbComm%kbLangCount%!"
  578. %kbLangSkip4%SET /A "kbLangCount=%kbLangCount%+1"
  579. %kbLangSkip4%ECHO [5] !lang%kbLangCount%! & SET "kbCComm5=!kbComm%kbLangCount%!"
  580. %kbLangSkip5%SET /A "kbLangCount=%kbLangCount%+1"
  581. %kbLangSkip5%ECHO [6] !lang%kbLangCount%! & SET "kbCComm6=!kbComm%kbLangCount%!"
  582. %kbLangSkip6%SET /A "kbLangCount=%kbLangCount%+1"
  583. %kbLangSkip6%ECHO [7] !lang%kbLangCount%! & SET "kbCComm7=!kbComm%kbLangCount%!"
  584. %kbLangSkip7%SET /A "kbLangCount=%kbLangCount%+1"
  585. %kbLangSkip7%ECHO [8] !lang%kbLangCount%! & SET "kbCComm8=!kbComm%kbLangCount%!"
  586. %kbLangSkip8%SET /A "kbLangCount=%kbLangCount%+1"
  587. %kbLangSkip8%ECHO [9] !lang%kbLangCount%! & SET "kbCComm9=!kbComm%kbLangCount%!"
  588. ECHO.
  589. %kbDisableNext%ECHO [N] Next Page
  590. %kbDisablePrev%ECHO [P] Previous Page
  591. ECHO [0] %kb0Opt% & ECHO [X] Exit
  592. IF "%kbSub%"=="true" (ECHO.) ELSE (ECHO Page %kbLangPageLoc%/%kbLangPages%)
  593. ECHO __________________________________________________________ &ECHO.
  594. IF %kbLangPageLoc% LSS %kbLangPages% (SET /A kbLangCount=%kbLangCount%-9) ELSE (SET /A kbLangCount=%kbLangCount%-%kbLangRemainder%)
  595. CHOICE /C %lC1%%lC2%%lC3%%lC4%%lC5%%lC6%%lC7%%lC8%%lC9%%lC10%%lC11%0X /N /M "%BS% Choose a menu option: "
  596. SET "kbChoice=%ERRORLEVEL%"
  597. IF %kbChoice%==1 ENDLOCAL & %kbCComm1%
  598. %kbLangSkip1%IF %kbChoice%==2 ENDLOCAL & %kbCComm2%
  599. %kbLangSkip2%IF %kbChoice%==3 ENDLOCAL & %kbCComm3%
  600. %kbLangSkip3%IF %kbChoice%==4 ENDLOCAL & %kbCComm4%
  601. %kbLangSkip4%IF %kbChoice%==5 ENDLOCAL & %kbCComm5%
  602. %kbLangSkip5%IF %kbChoice%==6 ENDLOCAL & %kbCComm6%
  603. %kbLangSkip6%IF %kbChoice%==7 ENDLOCAL & %kbCComm7%
  604. %kbLangSkip7%IF %kbChoice%==8 ENDLOCAL & %kbCComm8%
  605. %kbLangSkip8%IF %kbChoice%==9 ENDLOCAL & %kbCComm9%
  606. SET /A "lEL10=%lELs%"
  607. %kbDisableNext%SET /A "lEL10=%lEL10%+1"
  608. %kbDisableNext%IF %kbChoice%==%lEL10% (
  609. %kbDisableNext% SET /A kbLangPageLoc=%kbLangPageLoc%+1
  610. %kbDisableNext% SET /A kbLangCount=%kbLangCount%+9
  611. %kbDisableNext% GOTO KBLANG-MMS
  612. %kbDisableNext%)
  613. %kbDisablePrev%SET /A "lEL11=%lEL10%+1" & SET /A "lEL10=%lEL10%+1"
  614. %kbDisablePrev%IF %kbChoice%==%lEL11% (
  615. %kbDisablePrev% SET /A kbLangPageLoc=%kbLangPageLoc%-1
  616. %kbDisablePrev% SET /A kbLangCount=%kbLangCount%-9
  617. %kbDisablePrev% GOTO KBLANG-MMS
  618. %kbDisablePrev%)
  619. SET /A "lEL12=%lEL10%+1"
  620. IF %kbChoice%==%lEL12% (
  621. IF "%kbSub%"=="true" (ENDLOCAL & GOTO KBLANG-LANGS) ELSE (GOTO HOME-MAINMENU)
  622. )
  623. SET /A "lEL13=%lEL10%+2"
  624. IF %kbChoice%==%lEL13% EXIT /B 0
  625. GOTO KBLANG-MMS
  626. :KBLANG-DATABASE
  627. REM DB-Languages
  628. ::1 |United States| |Chinese| |Hindi (Devanagari) Traditional| |Spanish| |French|
  629. ::2 |Arabic| |Russian| |Bangla| |Portuguese| |Albanian|
  630. ::3 |Amharic| |Armenian| |Assamese - Inscript| |Azerbaijani| |Bashkir|
  631. ::4 |Belarusian| |Belgian| |Bosnian (Cyrillic)| |Buginese| |Bulgarian|
  632. ::5 |Canadian| |Central Atlas Tamazight| |Central Kurdish| |Cherokee| |Croatian|
  633. ::6 |Czech| |Danish| |Divehi| |Dutch| |Dzongkha|
  634. ::7 |Estonian| |Faeroese| |Finnish| |Futhark| |Georgian|
  635. ::8 |German| |Gothic| |Greek| |Greenlandic| |Guarani|
  636. ::9 |Gujarati| |Hausa| |Hebrew| |Hungarian| |Icelandic|
  637. ::10 |Igbo| |Indian| |Inuktitut| |Irish| |Italian|
  638. ::11 |Japanese NON-FUNCTIONAL| |Javanese| |Kannada| |Kazakh| |Khmer|
  639. ::12 |Konkoni (Devanagari) - INSCRIPT| |Korean| |Kyrgyz Cyrillic| |Lao| |Latin American|
  640. ::13 |Latvian| |Lisu| |Lithuanian| |Luxembourgish| |Macedonia|
  641. ::14 |Malayalam| |Maltese| |Maori| |Marathi| |Mongolian|
  642. ::15 |Myanmar| |N'ko| |Nepali| |New Tai Lue| |Norwegian|
  643. ::16 |Odia| |Ol Chiki| |Old Italic| |Osmanya| |Pashto (Afghanistan)|
  644. ::17 |Persian| |Phags-pa| |Polish| |Punjabi| |Romanian|
  645. ::18 |Sakha| |Sami| |Scottish Gaelic| |Serbian| |Sesotho sa Leboa|
  646. ::19 |Setswana| |Sinhala| |Slovak| |Slovenian| |Sora|
  647. ::20 |Sorbian| |Swedish| |Swiss| |Syriac| |Tai Le|
  648. ::21 |Tajik| |Tamil| |Tatar| |Telugu| |Thai|
  649. ::22 |Tibetan| |Tifinagh| |Tigrinya| |Turkish| |Turkmen|
  650. ::23 |Uyghur| |Ukrainian| |United Kingdom| |Urdu| |Uzbek|
  651. ::24 |Vietnamese| |Wolof| |Yakut| |Yoruba|
  652. REM DB-Corresponding Commands
  653. ::1 |US& GOTO KBLANG-SUBLANGS| |CHI& GOTO KBLANG-SUBLANGS| |0439:00010439& GOTO KBLANG-PRESET| |SPA& GOTO KBLANG-SUBLANGS| |040c:0000040c& GOTO KBLANG-PRESET|
  654. ::2 |ARA& GOTO KBLANG-SUBLANGS| |RUS& GOTO KBLANG-SUBLANGS| |BAN& GOTO KBLANG-SUBLANGS| |POR& GOTO KBLANG-SUBLANGS| |041c:0000041c& GOTO KBLANG-PRESET|
  655. ::3 |045e:{E429B25A-E5D3-4D1F-9BE3-0C608477E3A1}{8F96574E-C86C-4bd6-9666-3F7327D4CBE8}& GOTO KBLANG-PRESET| |ARM& GOTO KBLANG-SUBLANGS| |044d:0000044d& GOTO KBLANG-PRESET| |AZ& GOTO KBLANG-SUBLANGS| |046d:0000046d& GOTO KBLANG-PRESET|
  656. ::4 |0423:00000423& GOTO KBLANG-PRESET| |BEL& GOTO KBLANG-SUBLANGS| |141a:00000201a& GOTO KBLANG-PRESET| |0421:000b0c00& GOTO KBLANG-PRESET| |BUL& GOTO KBLANG-SUBLANGS|
  657. ::5 |CAN& GOTO KBLANG-SUBLANGS| |085f:0000085f& GOTO KBLANG-PRESET| |0429:00000429& GOTO KBLANG-PRESET| |CHE& GOTO KBLANG-SUBLANGS| |041a:0000041a& GOTO KBLANG-PRESET|
  658. ::6 |CZE& GOTO KBLANG-SUBLANGS| |0406:00000406& GOTO KBLANG-PRESET| |DIV& GOTO KBLANG-SUBLANGS| |0413:00000413& GOTO KBLANG-PRESET| |0C51:00000C51|
  659. ::7 |0425:00000425& GOTO KBLANG-PRESET| |0438:00000438& GOTO KBLANG-PRESET| |FIN& GOTO KBLANG-SUBLANGS| |0407:00120c00& GOTO KBLANG-PRESET| |GEO& GOTO KBLANG-SUBLANGS|
  660. ::8 |GER& GOTO KBLANG-SUBLANGS| |0407:000c0c00& GOTO KBLANG-PRESET| |GRE& GOTO KBLANG-SUBLANGS| |046f:0000046f& GOTO KBLANG-PRESET| |0474:00000474& GOTO KBLANG-PRESET|
  661. ::9 |0447:00000447& GOTO KBLANG-PRESET| |0468:00000468& GOTO KBLANG-PRESET| |040d:0000040d& GOTO KBLANG-PRESET| |HUN& GOTO KBLANG-SUBLANGS| |040f:0000040f& GOTO KBLANG-PRESET|
  662. ::10 |0470:00000470& GOTO KBLANG-PRESET| |4009:00004009& GOTO KBLANG-PRESET| |INU& GOTO KBLANG-SUBLANGS| |083C:000001809& GOTO KBLANG-PRESET| |ITA& GOTO KBLANG-SUBLANGS|
  663. ::11 |0411:{03B5835F-F03C-411B-9CE2-AA23E1171E36}{A76C93D9-5523-4E90-AAFA-4DB112F9AC76}& GOTO KBLANG-PRESET| |0421:00110c00& GOTO KBLANG-PRESET| |044b:0000044b& GOTO KBLANG-PRESET| |043f:0000043f& GOTO KBLANG-PRESET| |KHM& GOTO KBLANG-SUBLANGS|
  664. ::12 |0457:00000439& GOTO KBLANG-PRESET| |KOR& GOTO KBLANG-SUBLANGS| |0440:00000440& GOTO KBLANG-PRESET| |0454:00000454& GOTO KBLANG-PRESET| |080a:0000080a& GOTO KBLANG-PRESET|
  665. ::13 |LAT& GOTO KBLANG-SUBLANGS| |LIS& GOTO KBLANG-SUBLANGS| |LIT& GOTO KBLANG-SUBLANGS| |046e:0000046e& GOTO KBLANG-PRESET| |MAC& GOTO KBLANG-SUBLANGS|
  666. ::14 |044c:0000044c& GOTO KBLANG-PRESET| |MAL& GOTO KBLANG-SUBLANGS| |0481:00000481& GOTO KBLANG-PRESET| |044e:0000044e& GOTO KBLANG-PRESET| |MON& GOTO KBLANG-SUBLANGS|
  667. ::15 |0455:00010c00& GOTO KBLANG-PRESET| |0409:000090c00& GOTO KBLANG-PRESET| |0461:00000461& GOTO KBLANG-PRESET| |0409:00020c00& GOTO KBLANG-PRESET| |NOR& GOTO KBLANG-SUBLANGS|
  668. ::16 |0448:00000448& GOTO KBLANG-PRESET| |0409:d0c00& GOTO KBLANG-PRESET| |0409:000f0c00& GOTO KBLANG-PRESET| |0409:000e0c00& GOTO KBLANG-PRESET| |0463:00000463& GOTO KBLANG-PRESET|
  669. ::17 |PER& GOTO KBLANG-SUBLANGS| |0409:000a0c00& GOTO KBLANG-PRESET| |POL& GOTO KBLANG-SUBLANGS| |0446:00000446& GOTO KBLANG-PRESET| |ROM& GOTO KBLANG-SUBLANGS|
  670. ::18 |0485:00000485& GOTO KBLANG-PRESET| |SAM& GOTO KBLANG-SUBLANGS| |0809:00011809& GOTO KBLANG-PRESET| |SER& GOTO KBLANG-SUBLANGS| |046c:0000046c& GOTO KBLANG-PRESET|
  671. ::19 |0432:00000432& GOTO KBLANG-PRESET| |SIN& GOTO KBLANG-SUBLANGS| |SLO& GOTO KBLANG-SUBLANGS| |0424:00000424& GOTO KBLANG-PRESET| |0409:00100c00& GOTO KBLANG-PRESET|
  672. ::20 |SOR& GOTO KBLANG-SUBLANGS| |SWE& GOTO KBLANG-SUBLANGS| |SWI& GOTO KBLANG-SUBLANGS| |SYR& GOTO KBLANG-SUBLANGS| |0409:00030c00& GOTO KBLANG-PRESET|
  673. ::21 |0428:00000428& GOTO KBLANG-PRESET| |TAM& GOTO KBLANG-SUBLANGS| |TAT& GOTO KBLANG-SUBLANGS| |044a:0000044a& GOTO KBLANG-PRESET| |THA& GOTO KBLANG-SUBLANGS|
  674. ::22 |TIB& GOTO KBLANG-SUBLANGS| |TIF& GOTO KBLANG-SUBLANGS| |0473:{E429B25A-E5D3-4D1F-9BE3-0C608477E3A1}{3CAB88B7-CC3E-46A6-9765-B772AD7761FF}& GOTO KBLANG-PRESET| |TUR& GOTO KBLANG-SUBLANGS| |0442:00000442& GOTO KBLANG-PRESET|
  675. ::23 |UYG& GOTO KBLANG-SUBLANGS| |UKR& GOTO KBLANG-SUBLANGS| |UK& GOTO KBLANG-SUBLANGS| |0420:00000420| |0843:00000843|
  676. ::24 |VIE& GOTO KBLANG-SUBLANGS| |0488:00000488& GOTO KBLANG-PRESET| |0485:00000485& GOTO KBLANG-PRESET| |046a:0000056a& GOTO KBLANG-PRESET|
  677. REM DB-Submenu Input Methods
  678. :: |ARA| |Arabic (101)| |Arabic (102)| |Arabic (102 AZERTY)|
  679. :: |ARM| |Armenian Eastern| |Armenian Phonetic| |Armenian Typewriter| |Armenian Western|
  680. :: |AZE| |Azerbaijani (Standard)| |Azerbaijani Cyrillic| |Azerbaijani Latin|
  681. :: |BEL| |Belgian (Comma)| |Belgian (Period)| |Belgian French|
  682. :: |BAN| |Bangla (Bangladesh)| |Bangla (India)| |Bangla (India) - Legacy|
  683. :: |BUL| |Bulgarian| |Bulgarian Latin| |Bulgarian (Phonetic Layout)| |Bulgarian (Phonetic Traditonal)| |Bulgarian (Typewriter)|
  684. :: |CAN| |Canadian French| |Canadian French (Legacy)| |Canadian Multilingual Standard|
  685. :: |CHE| |Cherokee Nation| |Cherokee Nation Phonetic|
  686. :: |CHI| |Chineese (Simplified)| |Chineese (Traditional) NON-FUNCTIONAL| |Chineese (Traditional, Hong Kong S.A.R.)| |Chineese (Traditonal Macao S.A.R.)| |Chineese (Simplified, Singapore)|
  687. :: |CZE| |Czech| |Czech (QWERTY)| |Czech Programmers|
  688. :: |DIV| |Divehi Phonetic| |Divehi Typewriter|
  689. :: |FIN| |Finnish| |Finnish with Sami|
  690. :: |GEO| |Georgian| |Georgian (Ergonomic)| |Georgian (QWERTY)| |Georgian Ministry of Education and Science Schools| |Georgian (Old Alphabets)|
  691. :: |GER| |German| |German (IBM)|
  692. :: |GRE| |Greek| |Greek (220)| |Greek (220) Latin| |Greek (319)| |Greek (319) Latin| |Greek Latin| |Greek Polytonic|
  693. :: |HUN| |Hungarian| |Hungarian 101-key|
  694. :: |INU| |Inuktitut - Latin| |Inuktitut - Naqittaut|
  695. :: |ITA| |Italian| |Italian (142)|
  696. :: |KHM| |Khmer| |Khmer (NIDA)|
  697. :: |KOR| |Korean (Hangul)| |Korean (Old Hangul)|
  698. :: |LAT| |Latvian (Standard)| |Latvian (Legacy)|
  699. :: |LIS| |Lisu (Basic)| |Lisu (Standard)|
  700. :: |LIT| |Lithuanian| |Lithuanian IBM| |Lithuanian Standard|
  701. :: |MAC| |Macedonian (FYROM)| |Macedonian (FYROM) - Standard|
  702. :: |MAL| |Maltese 47-key| |Maltese 48-key|
  703. :: |MON| |Mongoloian (Mongolian Script - Legacy)| |Mongolian (Mongolian Script - Standard)| |Mongolian Cyrillic|
  704. :: |NOR| |Norwegian| |Norwegian with Sami|
  705. :: |PER| |Persian| |Persian (Standard)|
  706. :: |POL| |Polish (214)| |Polish (Programmers)|
  707. :: |POR| |Portuguese| |Portuguese (Brazilian ABNT)| |Portuguese (Brazilian ABNT2)|
  708. :: |ROM| |Romanian (Legacy)| |Romanian (Programmers) |Romanian (Standard)|
  709. :: |RUS| |Russian| |Russian - Mnemonic| |Russian (Typewriter)|
  710. :: |SAM| |Sami Extended Finland-Sweden| |Sami Extended Norway|
  711. :: |SER| |Serbian (Cyrillic)| |Serbian (Latin)|
  712. :: |SIN| |Sinhala| |Sinhala - wij 9|
  713. :: |SLO| |Slovak| |Slovak (QWERTY)|
  714. :: |SOR| |Sorbian Extended| |Sorbian Standard| |Sorbian Standard (Legacy)|
  715. :: |SPA| |Spanish (Spain)| |Spanish (Mexico)| |Spanish Variation|
  716. :: |SWE| |Swedish| |Swedish with Sami|
  717. :: |SWI| |Swiss French| |Swiss German|
  718. :: |SYR| |Syriac| |Syriac Phonetic|
  719. :: |TAM| |Tamil| |Tamil (99 Keyboard)|
  720. :: |TAT| |Tatar| |Tatar (Legacy)|
  721. :: |THA| |Thai Kedmanee| |Thai Kedmanee (non-ShiftLock)| |Thai Pattachote| |Thai Pattachote (non-ShiftLock)|
  722. :: |TIB| |Tibetan (PRC - Standard)| |Tibetan (PRC - Legacy)|
  723. :: |TIF| |Tifinagh (Basic)| |Tifinagh (Full)|
  724. :: |TUR| |Turkish F| |Turkish Q|
  725. :: |UYG| |Uyghur| |Uygher (Legacy)| |Uyghur (Greek 220)|
  726. :: |UKR| |Ukrainian| |Ukrainian (Enhanced)|
  727. :: |UK| |United Kingdom| |United Kingdom Extended|
  728. :: |US| |United States - English| |United States - International| |United States - Dvorak| |United States - Dvorak (Left Hand)| |United States - Dvorak (Right Hand)|
  729. :: |VIE| |Vietnamese| |Vietnamese Telex|
  730. REM DB-SubCorresponding Input Methods
  731. :: |ARA| |0401:00000401| |0401:00010401| |0401:00020401|
  732. :: |ARM| |042b:0000042b| |042b:0002042b| |042b:0003042b| |042b:0001042b|
  733. :: |AZE| |042c:0001042c| |042c:0000082c| |042c:0000042c|
  734. :: |BEL| |080c:0001080c| |080c:00000813| |080c:0000080c|
  735. :: |BAN| |0445:00000445| |0445:00020445| |0445:00010445|
  736. :: |BUL| |042b:0003042b| |042b:0001042b| |042b:0002042b| |042b:0004042b| |042b:0000042b|
  737. :: |CAN| |0c0c:00001009| |0c0c:00000c0c| |0c0c:00011009|
  738. :: |CHE| |045c:0000045c| |045c:0001045c|
  739. :: |CHI| |0804:{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}{FA550B04-5AD7-411f-A5AC-CA038EC515D7}| |0404:{B115690A-EA02-48D5-A231-E3578D2FDF80}{B2F9C502-1742-11D4-9790-0080C882687E}| |0404:00000c04| |0404:00001404| |0404:00001004|
  740. :: |CZE| |2000:00000405| |2000:00010405| |2000:00020405|
  741. :: |DIV| |0465:00000465| |0465:00010465|
  742. :: |FIN| |040b:0000040b| |040b:0001083b|
  743. :: |GEO| |0437:00020437| |0437:00010437| |0437:00030437| |0437:00040437|
  744. :: |GER| |0407:00000407| |0407:00010407|
  745. :: |GRE| |0408:00000408| |0408:00010408| |0408:00030408| |0408:00020408| |0408:00040408| |0408:00050408| |0408:00600408|
  746. :: |HUN| |040e:0000040e| |040e:0001040e|
  747. :: |INU| |085d:0000085d| |085d:0001045d|
  748. :: |ITA| |0410:00000410| |0410:00010410|
  749. :: |KHM| |0453:00000453| |0453:00010453|
  750. :: |KOR| |0412:{A028AE76-01B1-46C2-99C4-ACD9858AE02F}{B5FE1F02-D5F2-4445-9C03-C568F23C99A1}| |0412:{a1e2b86b-924a-4d43-80f6-8a820df7190f}{b60af051-257a-46bc-b9d3-84dad819bafb}|
  751. :: |LAT| |0426:00020426| |0426:00010426|
  752. :: |LIS| |0409:00070c00| |0409:00080c00|
  753. :: |LIT| |0427:00010427| |0427:00000427| |0427:00020427|
  754. :: |MAC| |042f:0000042f| |042f:0001042f|
  755. :: |MAL| |043a:0000043a| |043a:0001043a|
  756. :: |MON| |0850:00000850| |0850:00020850| |0850:00000450|
  757. :: |NOR| |0814:00000414| |0814:0000043b|
  758. :: |PER| |0429:00000429| |0429:00050429|
  759. :: |POL| |0415:00010415| |0415:00000415|
  760. :: |POR| |0816:00000816| |0816:00000416| |0816:00010416|
  761. :: |ROM| |0418:00000418| |0418:00020418| |0418:00010418|
  762. :: |RUS| |0419:00000419| |0419:00020419| |0419:00010419|
  763. :: |SAM| |083b:0002083b| |043b:0001043b|
  764. :: |SER| |1C1A:00000c1a| |241A:0000081a|
  765. :: |SIN| |045b:0000045b| |045b:0001045b|
  766. :: |SLO| |041b:0000041b| |041b:0001041b|
  767. :: |SOR| |042e:0001042e| |042e:0002042e| |042e:0000042e|
  768. :: |SPA| |0c0a:0000040a| |080a:0000080a| |0c0a:0001040a|
  769. :: |SWE| |041d:0000041d| |083b:0000083b|
  770. :: |SWI| |100c:0000100c| |0807:00000807|
  771. :: |SYR| |045a:0000045a| |045a:0001045a|
  772. :: |TAM| |0449:00000449| |0449:00020449|
  773. :: |TAT| |0444:00010444| |0444:00000444|
  774. :: |THA| |041e:0000041e| |041e:0002041e| |041e:0001041e| |041e:0003041e|
  775. :: |TIB| |0451:00010451| |0451:00000451|
  776. :: |TIF| |0409:00050c00| |0409:00050c00|
  777. :: |TUR| |041f:0001041f| |041f:0000041f|
  778. :: |UYG| |0480:00010480| |0480:00000480| |0480:00010408|
  779. :: |UKR| |0422:00000422| |0422:00020422|
  780. :: |UK| |0809:00000809| |0809:00000452|
  781. :: |US| |0409:00000409| |0409:00020409| |0409:00010409| |0409:00030409| |0409:00040409|
  782. :: |VIE| |042a:0000042a| |042A:{C2CB2CF0-AF47-413E-9780-8BC3A3C16068}{5FB02EC5-0A77-4684-B4FA-DEF8A2195628}|
  783. REM Marker
  784. :KBLANG-PRESET
  785. IF /I "%~1"=="kbLangSet" WAITFOR /SI Golden>NUL 2>&1 & SET "kbLangSel=%~2" & SET "kbMakeDef=%~3" & GOTO KBLANG-SETLANG
  786. SETLOCAL
  787. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO.
  788. CHOICE /C YN /N /M "%BS% Make default keyboard language? (Y/N): "
  789. IF %ERRORLEVEL%==2 SET "kbMakeDef=false"
  790. ECHO. & ECHO Adding keyboard language...
  791. TIMEOUT /T 1 /NOBREAK > NUL
  792. POWERSHELL -NoP -C "(Get-WmiObject Win32_Process -Filter ProcessId=$PID).ParentProcessId" > %temp%\CentralAMEProcessID.txt
  793. FOR /F "delims=" %%A IN (%temp%\CentralAMEProcessID.txt) DO SET "scriptPID=%%A" & DEL "%temp%\CentralAMEProcessID.txt"
  794. REM Detects if the script is being run under the currently logged in user. If not it runs a second instance as the current user
  795. FOR /F tokens^=2^ delims^=^" %%A IN ('TASKLIST /FI "PID eq %scriptPID%" /FI "USERNAME eq %currentUsername%" /NH /FO csv') DO SET processRunOut=%%A
  796. IF NOT "%processRunOut%"=="," (
  797. REM If %lim% = rem that means the script is NOT being run as administrator. There's a small chance someone attempts to run it as another non-admin user,
  798. REM this would be problematic as schtasks requires admin privilages.
  799. IF "%lim%"=="rem " ECHO. & ECHO. & ECHO Script must be run as the current user & ECHO or with administrator privilages. & ECHO __________________________________________________________ & ECHO. & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU
  800. SETLOCAL ENABLEDELAYEDEXPANSION
  801. SCHTASKS /CREATE /tn SetDispLang /tr "CMD /C 'START /min '' '%scriptPath%' kbLangSet %kbLangSel% %kbMakeDef%'" /sc ONSTART /ru "%currentUsername%" /it /f > NUL
  802. REM RUNAS will work, however it requires the user to enter a password, and won't accept a blank one. This is a lot more simple and reliable
  803. SCHTASKS /RUN /tn SetDispLang > NUL
  804. WAITFOR Golden /T 10 > NUL 2>&1
  805. IF !ERRORLEVEL! LSS 1 SCHTASKS /DELETE /tn SetDispLang /f>NUL & GOTO KBLANG-COMPLETE
  806. SCHTASKS /DELETE /tn SetDispLang /f > NUL
  807. ENDLOCAL & ENDLOCAL & ECHO. & ECHO. & ECHO Action failed. & ECHO __________________________________________________________ & ECHO. & PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu: & GOTO HOME-MAINMENU )
  808. :KBLANG-SETLANG
  809. POWERSHELL -NoP -C "$NewLangs=Get-WinUserLanguageList; $NewLangs[0].InputMethodTips.Add('%kbLangSel%'); Set-WinUserLanguageList $NewLangs -Force" > NUL
  810. IF NOT "%kbMakeDef%"=="false" POWERSHELL -NoP -C "Set-WinDefaultInputMethodOverride -InputTip "%kbLangSel%""
  811. IF /I "%~1"=="kbLangSet" EXIT 0
  812. :KBLANG-COMPLETE
  813. ECHO. & ECHO. & ECHO Keyboard language added successfully & ECHO __________________________________________________________ & ECHO.
  814. ENDLOCAL
  815. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  816. GOTO HOME-MAINMENU
  817. REM -------------------------KBLANG-END-------------------------
  818. REM -------------------------NOUSERNAME-------------------------
  819. :NOUSERNAME-MENU
  820. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO. & ECHO [1] Disable Username Requirement & ECHO [2] Enable Username Requirement & ECHO. & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO. & ECHO __________________________________________________________ & ECHO.
  821. CHOICE /C 120X /N /M "%BS% Choose a menu option: "
  822. IF %ERRORLEVEL%==1 SET "wshMenu=1" & GOTO NOUSERNAME-DISABLE
  823. IF %ERRORLEVEL%==2 SET "wshMenu=2" & GOTO NOUSERNAME-ENABLE
  824. IF %ERRORLEVEL%==3 GOTO HOME-MAINMENU
  825. IF %ERRORLEVEL%==4 EXIT /B 0
  826. :NOUSERNAME-DISABLE
  827. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO.
  828. TIMEOUT /T 1 /NOBREAK > NUL
  829. REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v dontdisplaylastusername /f > NUL 2>&1
  830. ECHO. & ECHO The username login requirement is now disabled & ECHO A restart is needed to take effect. & ECHO __________________________________________________________ & ECHO.
  831. CHOICE /C YN /N /M "%BS% Would you like to restart now? (Y/N): "
  832. IF %ERRORLEVEL%==1 SHUTDOWN -R -T 0 & EXIT 0
  833. IF %ERRORLEVEL%==2 GOTO HOME-MAINMENU
  834. :NOUSERNAME-ENABLE
  835. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO.
  836. TIMEOUT /T 1 /NOBREAK > NUL
  837. REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v dontdisplaylastusername /t REG_DWORD /d 1 /f > NUL 2>&1
  838. ECHO. & ECHO The username login requirement is now enabled & ECHO A restart is needed to take effect. & ECHO __________________________________________________________ & ECHO.
  839. CHOICE /C YN /N /M "%BS% Would you like to restart now? (Y/N): "
  840. IF %ERRORLEVEL%==1 SHUTDOWN -R -T 0 & EXIT 0
  841. IF %ERRORLEVEL%==2 GOTO HOME-MAINMENU
  842. REM -----------------------NOUSERNAME-END-----------------------
  843. REM ----------------------------WSH-----------------------------
  844. :WSH-MENU
  845. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO. & ECHO [1] Enable WSH & ECHO [2] Disable WSH & ECHO. & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO. & ECHO __________________________________________________________ & ECHO.
  846. CHOICE /C 120X /N /M "%BS% Choose a menu option: "
  847. IF %ERRORLEVEL%==1 SET "wshMenu=1" & GOTO WSH-ENABLE
  848. IF %ERRORLEVEL%==2 SET "wshMenu=2" & GOTO WSH-DISABLE
  849. IF %ERRORLEVEL%==3 GOTO HOME-MAINMENU
  850. IF %ERRORLEVEL%==4 EXIT /B 0
  851. :WSH-ENABLE
  852. SET "cenStr=Enabling WSH for %currentUsername%..." & CALL :AUX-CENTERTEXT
  853. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO%cenOut%
  854. TIMEOUT /T 2 /NOBREAK > NUL
  855. FOR /F "tokens=* USEBACKQ" %%F IN (`WMIC useraccount where "name="%currentUsername%"" get sid ^| FINDSTR "S-"`) DO SET WSHSID=%%F
  856. SET WSHSID=%WSHSID:~0,-3%
  857. REG ADD "HKEY_USERS\%WSHSID%\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 1 /f > NUL
  858. REG ADD "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 1 /f > NUL
  859. GOTO WSH-FINISH
  860. :WSH-DISABLE
  861. SET "cenStr=Disabling WSH for %currentUsername%..." & CALL :AUX-CENTERTEXT
  862. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO%cenOut%
  863. TIMEOUT /T 2 /NOBREAK > NUL
  864. FOR /F "tokens=* USEBACKQ" %%F IN (`WMIC useraccount where "name="%currentUsername%"" get sid ^| FINDSTR "S-"`) DO SET WSHSID=%%F
  865. SET WSHSID=%WSHSID:~0,-3%
  866. REG ADD "HKEY_USERS\%WSHSID%\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 0 /f > NUL
  867. REG ADD "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 0 /f > NUL
  868. GOTO WSH-FINISH
  869. :WSH-FINISH
  870. IF "%wshMenu%"=="1" SET "cenStr=WSH is now enabled for %currentUsername%" & SET "wshRestartMsg=& ECHO A restart is required to complete the setup. "
  871. IF "%wshMenu%"=="2" SET "cenStr=WSH is now disabled for %currentUsername%" & SET "wshRestartMsg="
  872. CALL :AUX-CENTERTEXT
  873. ECHO. & ECHO. & ECHO%cenOut:~1% %wshRestartMsg%& ECHO __________________________________________________________ & ECHO.
  874. IF "%wshMenu%"=="1" CHOICE /C YN /N /M "%BS% Would you like to restart now? (Y/N): "
  875. IF %ERRORLEVEL%==1 SHUTDOWN -R -T 0 & EXIT 0
  876. IF %ERRORLEVEL%==2 GOTO HOME-MAINMENU
  877. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  878. GOTO HOME-MAINMENU
  879. REM --------------------------WSH-END--------------------------
  880. REM ---------------------------NCSI----------------------------
  881. :NCSI-MENU
  882. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO. & ECHO [1] Enable NCSI Active Probing & ECHO [2] Disable NCSI Active Probing & ECHO. & ECHO [0] Return to Menu & ECHO [X] Exit & ECHO. & ECHO __________________________________________________________ & ECHO.
  883. CHOICE /C 120X /N /M "%BS% Choose a menu option: "
  884. IF %ERRORLEVEL%==1 SET "ncsiMenu=1" & GOTO NCSI-ENABLE
  885. IF %ERRORLEVEL%==2 SET "ncsiMenu=2" & GOTO NCSI-DISABLE
  886. IF %ERRORLEVEL%==3 GOTO HOME-MAINMENU
  887. IF %ERRORLEVEL%==4 EXIT /B 0
  888. :NCSI-ENABLE
  889. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO Enabling NCSI Active Probing...
  890. TIMEOUT /T 2 /NOBREAK > NUL
  891. REG ADD "HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" /v EnableActiveProbing /t REG_DWORD /d 1 /f > NUL
  892. GOTO NCSI-FINISH
  893. :NCSI-DISABLE
  894. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO Disabling NCSI Active Probing...
  895. TIMEOUT /T 2 /NOBREAK > NUL
  896. REG ADD "HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" /v EnableActiveProbing /t REG_DWORD /d 0 /f > NUL
  897. GOTO NCSI-FINISH
  898. :NCSI-FINISH
  899. IF "%ncsiMenu%"=="1" SET "ncsiResult= NCSI Active Probing is now disabled"
  900. IF "%ncsiMenu%"=="2" SET "ncsiResult= NCSI Active Probing is now enabled"
  901. ECHO. & ECHO. & ECHO %ncsiResult% & ECHO A restart is required to take effect. & ECHO __________________________________________________________ & ECHO.
  902. CHOICE /C YN /N /M "%BS% Would you like to restart now? (Y/N): "
  903. IF %ERRORLEVEL%==1 SHUTDOWN -R -T 0 & EXIT 0
  904. IF %ERRORLEVEL%==2 GOTO HOME-MAINMENU
  905. REM -------------------------NCSI-END--------------------------
  906. REM ----------------
  907. REM Script Functions
  908. REM ----------------
  909. REM -----------------------------------------------------------
  910. :AUX-UPDATE
  911. CLS & ECHO. & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO Downloading and applying update...
  912. TIMEOUT /T 1 /NOBREAK > NUL
  913. CURL -L "https://git.ameliorated.info/Joe/Central-AME-Script/releases/latest/CentralAMEScript.zip" --output "%temp%\AMECentralUpdated.zip" > NUL 2>&1
  914. REM Detect size of update CMD file, this essentially allows for a simple error detection.
  915. FOR %%A IN ("%temp%\AMECentralUpdated.zip") DO SET "updCmdSize=%%~zA"
  916. IF %updCmdSize% LSS 7000 (
  917. DEL /Q "%temp%\AMECentralUpdated.zip" > NUL
  918. GOTO AUX-UPDATEFAILED )
  919. POWERSHELL -command "Expand-Archive -Path '%temp%\AMECentralUpdated.zip' -DestinationPath '%temp%'" > NUL
  920. > NUL 2>&1 XCOPY "%temp%\CentralAMEScript.cmd" "%scriptPath%" /Y /V /O & DEL /Q "%temp%\AMECentralUpdated.cmd" & CMD /C "%~0" updateFinished & EXIT 0
  921. :AUX-UPDATEFAILED
  922. ECHO. & ECHO. & ECHO Download failed. & ECHO __________________________________________________________ & ECHO.
  923. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  924. GOTO HOME-MAINMENU
  925. :AUX-UPDATEFINISHED
  926. ECHO. & ECHO Script update successful & ECHO __________________________________________________________ & ECHO. & ECHO ^| Central AME Script %ver% ^| & ECHO. & ECHO Downloading and applying update... & ECHO. & ECHO. & ECHO Script Update Successful & ECHO __________________________________________________________ & ECHO.
  927. PAUSE > NUL|SET /P =%BS% Press any key to return to the Menu:
  928. GOTO HOME-MAINMENU
  929. REM -----------------------------------------------------------
  930. REM -----------------------------------------------------------
  931. :AUX-CENTERTEXT
  932. SET "cenSize=58"
  933. SET "offset= "
  934. SET "LEN=0"
  935. :CENTERTEXT-LOOP
  936. SETLOCAL ENABLEDELAYEDEXPANSION
  937. IF "!!cenStr:~%LEN%!!"=="" ENDLOCAL & GOTO CENTERTEXT-LOOPEND
  938. SET /A "LEN=%LEN%+1"
  939. FOR %%B IN ('%LEN%') DO ENDLOCAL & SET "LEN=%%B"
  940. SET "LEN=%LEN:~1,-1%
  941. GOTO CENTERTEXT-LOOP
  942. :CENTERTEXT-LOOPEND
  943. SET "compare=__________________________________________________________"
  944. SET "spaces= "
  945. SET /A "pref_len=%cenSize%-%LEN%-2" & SET /A "pref_len/=2"
  946. SET /A "suf_len=%cenSize%-%LEN%-2-%pref_len%"
  947. CALL SET "cenOutput=%%offset%%%%spaces:~0,%pref_len%%%%%CENSTR%%"
  948. FOR /F "delims=" %%B in ("%cenOutput%") DO ENDLOCAL & SET "cenOut=%%B"
  949. EXIT /B 0
  950. REM -----------------------------------------------------------
  951. REM -----------------------------------------------------------
  952. :AUX-GETUSERNAME
  953. REM Grabs current username. %username% can be problematic and %userprofile%
  954. REM is hard to filter properly, thus why this method is used.
  955. FOR /F "tokens=2 delims=\" %%B IN ('WMIC computersystem get username') DO SET currentUsername=%%B
  956. SET "currentUsername=%currentUsername:~0,-3%"
  957. REM Detection for if user changed their username without restarting
  958. IF "%currentUsername%"=="~0,-3" SET "currentUsername=RestartRequired"
  959. SET "possibleUserDir=%currentUsername:~0,5%"
  960. EXIT /B 0
  961. REM -----------------------------------------------------------
  962. REM -----------------------------------------------------------
  963. :AUX-ELEVATIONCHECK
  964. SET "elevCheckUsername="%currentUsername%""
  965. IF /I "%currentUsername%"=="RestartRequired" SET "elevCheckUsername="
  966. FOR /F "delims=" %%A IN ('NET user %elevCheckUsername% ^| FIND "Local Group Memberships"') DO SET "elevResult=%%A" > NUL 2>&1
  967. ECHO "%elevResult%" | FINDSTR "Administrators" > NUL 2>&1
  968. IF %ERRORLEVEL% LEQ 0 SET "userStatus=Elevated"
  969. IF %ERRORLEVEL% GTR 0 SET "userStatus=Not Elevated"
  970. IF /I "%currentUsername%"=="" SET "currentUsername=RestartRequired"
  971. EXIT /B 0
  972. REM -----------------------------------------------------------