patch.cmd 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. @echo off
  2. rem ================================================================================
  3. for %%a in ("%~dp0\.") do set "SnPatchVersion=%%~nxa"
  4. rem ================================================================================
  5. rem ‚�ˆŒ€�ˆ…!!! ’¥ªáâ á®®¡é¥­¨© ¤«ï ¢ë¢®¤  ¢ ä ©« ᤥ« ­ ¢ ª®¤¨à®¢ª¥ CP1251!
  6. rem ================================================================================
  7. rem ‘®å࠭塞 ⥪ãéãî ª®¤®¢ãî áâà ­¨æã
  8. for /f "tokens=2 delims=:" %%i in ('chcp') do (set codepage_old=%%i)
  9. set codepage_old=%codepage_old:~1,9%
  10. rem ================================================================================
  11. rem �஢¥àª  ­  ­ «¨ç¨¥ ¯à ¢  ¤¬¨­¨áâà â®à 
  12. if '%1'=='ELEV' (shift /1 & goto Install)
  13. >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  14. if %errorlevel% neq 0 (
  15. goto Elevate
  16. )
  17. :Install
  18. rem ================================================================================
  19. rem �ਠ­ «¨ç¨¨ ¯ à ¬¥âà  íâ® ¤®«¦¥­ ¡ëâì ª â «®£ ¤«ï «®£®¢ ãáâ ­®ª¨ ¯ âç 
  20. set log_dir=%~1
  21. if ^"%log_dir%^" neq "" (
  22. set fin=%log_dir:~-1%
  23. if "%fin%" neq "\" (set log_dir=%log_dir%\)
  24. )
  25. rem ================================================================================
  26. rem �®«ã祭¨¥ ¯ã⥩
  27. rem �ãâì ¤«ï ª®­á®«¨ ã¯à ¢«¥­¨ï
  28. reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v ControlCenterDir > nul 2> nul
  29. if "%log_dir%" neq "" (
  30. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïîëó÷èòü ïóòü óñòàíîâêè ïðîäóêòà"
  31. ) else (
  32. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯®«ãç¨âì ¯ãâì ãáâ ­®¢ª¨ ¯à®¤ãªâ "
  33. )
  34. FOR /F "usebackq tokens=2,* skip=2" %%L IN (
  35. `reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v ControlCenterDir`
  36. ) DO SET consolepath=%%M
  37. if %consolepath:~-1% EQU \ set consolepath=%consolepath:~0,-1%
  38. rem �ã⨠á¨á⥬­ëå ä ©«®¢
  39. set Sys32=%systemroot%\System32
  40. set SysWOW=%systemroot%\SysWOW64
  41. rem �ãâì ¤à ©¢¥à®¢
  42. rem set SysDrv=%systemroot%\System32\drivers
  43. rem ================================================================================
  44. rem Žá­®¢­ ï à ¡®â  ¯® ãáâ ­®¢ª¥ ¯ âç 
  45. rem Ž¯¥à æ¨ï ¢ § ¢¨á¨¬®á⨠®â à §à來®áâ¨
  46. if "%PROCESSOR_ARCHITECTURE%"=="x86" (
  47. call :PatchX86
  48. ) else (
  49. call :PatchX64
  50. )
  51. rem ================================================================================
  52. if "%log_dir%" neq "" (
  53. chcp 1251 >nul 2>&1
  54. echo Ïàò÷ óñòàíîâëåí óñïåøíî > "%log_dir%success.%computername%.%userdomain%.patch_%SnPatchVersion%.log"
  55. chcp %codepage_old% >nul 2>&1
  56. ) else (
  57. color 0A
  58. echo � âç ãáâ ­®¢«¥­ ãᯥ譮
  59. pause
  60. )
  61. exit /b
  62. rem ================================================================================
  63. :PatchX86
  64. rem ‡ ¬¥­  ä ©«  á á®åà ­¥­¨¥¬ áâ à®© ¢¥àᨨ
  65. Setlocal EnableDelayedExpansion
  66. call :GetVersion "%consolepath%\lc.dll"
  67. Setlocal DisableDelayedExpansion
  68. ren "%consolepath%\lc.dll" "lc.dll%file_old_version%"
  69. if "%log_dir%" neq "" (
  70. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë lc.dll"
  71. ) else (
  72. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« lc.dll"
  73. )
  74. copy "%~dp0Module\win32\lc.dll" "%consolepath%"
  75. if "%log_dir%" neq "" (
  76. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë lc.dll"
  77. ) else (
  78. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« lc.dll"
  79. )
  80. ren "%consolepath%\en-US\lc.dll.mui" "lc.dll.mui%file_old_version%"
  81. if "%log_dir%" neq "" (
  82. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë en-US\lc.dll.mui"
  83. ) else (
  84. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« en-US\lc.dll.mui"
  85. )
  86. copy "%~dp0Module\win32\en-US\lc.dll.mui" "%consolepath%\en-US"
  87. if "%log_dir%" neq "" (
  88. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë en-US\lc.dll.mui"
  89. ) else (
  90. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« en-US\lc.dll.mui"
  91. )
  92. ren "%consolepath%\ru-RU\lc.dll.mui" "lc.dll.mui%file_old_version%"
  93. if "%log_dir%" neq "" (
  94. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë ru-RU\lc.dll.mui"
  95. ) else (
  96. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« ru-RU\lc.dll.mui"
  97. )
  98. copy "%~dp0Module\win32\ru-RU\lc.dll.mui" "%consolepath%\ru-RU"
  99. if "%log_dir%" neq "" (
  100. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë ru-RU\lc.dll.mui"
  101. ) else (
  102. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« ru-RU\lc.dll.mui"
  103. )
  104. rem ‡ ¬¥­  ä ©«  á á®åà ­¥­¨¥¬ áâ à®© ¢¥àᨨ
  105. Setlocal EnableDelayedExpansion
  106. call :GetVersion "%consolepath%\Medusa.exe"
  107. Setlocal DisableDelayedExpansion
  108. ren "%consolepath%\Medusa.exe" "Medusa.exe%file_old_version%"
  109. if "%log_dir%" neq "" (
  110. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë Medusa.exe"
  111. ) else (
  112. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« Medusa.exe"
  113. )
  114. copy "%~dp0Module\win32\Medusa.exe" "%consolepath%"
  115. if "%log_dir%" neq "" (
  116. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë Medusa.exe"
  117. ) else (
  118. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« Medusa.exe"
  119. )
  120. ren "%consolepath%\en-US\Medusa.resources.dll" "Medusa.resources.dll%file_old_version%"
  121. if "%log_dir%" neq "" (
  122. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë en-US\Medusa.resources.dll"
  123. ) else (
  124. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« en-US\Medusa.resources.dll"
  125. )
  126. copy "%~dp0Module\win32\en-US\Medusa.resources.dll" "%consolepath%\en-US"
  127. if "%log_dir%" neq "" (
  128. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë en-US\Medusa.resources.dll"
  129. ) else (
  130. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« en-US\Medusa.resources.dll"
  131. )
  132. ren "%consolepath%\ru-RU\Medusa.resources.dll" "Medusa.resources.dll%file_old_version%"
  133. if "%log_dir%" neq "" (
  134. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë ru-RU\Medusa.resources.dll"
  135. ) else (
  136. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« ru-RU\Medusa.resources.dll"
  137. )
  138. copy "%~dp0Module\win32\ru-RU\Medusa.resources.dll" "%consolepath%\ru-RU"
  139. if "%log_dir%" neq "" (
  140. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë ru-RU\Medusa.resources.dll"
  141. ) else (
  142. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« ru-RU\Medusa.resources.dll"
  143. )
  144. exit /b
  145. rem ================================================================================
  146. :PatchX64
  147. rem ‡ ¬¥­  ä ©«  á á®åà ­¥­¨¥¬ áâ à®© ¢¥àᨨ
  148. Setlocal EnableDelayedExpansion
  149. call :GetVersion "%consolepath%\lc.dll"
  150. Setlocal DisableDelayedExpansion
  151. ren "%consolepath%\lc.dll" "lc.dll%file_old_version%"
  152. if "%log_dir%" neq "" (
  153. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë lc.dll"
  154. ) else (
  155. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« lc.dll"
  156. )
  157. copy "%~dp0Module\x64\lc.dll" "%consolepath%"
  158. if "%log_dir%" neq "" (
  159. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë lc.dll"
  160. ) else (
  161. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« lc.dll"
  162. )
  163. ren "%consolepath%\en-US\lc.dll.mui" "lc.dll.mui%file_old_version%"
  164. if "%log_dir%" neq "" (
  165. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë en-US\lc.dll.mui"
  166. ) else (
  167. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« en-US\lc.dll.mui"
  168. )
  169. copy "%~dp0Module\x64\en-US\lc.dll.mui" "%consolepath%\en-US"
  170. if "%log_dir%" neq "" (
  171. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë en-US\lc.dll.mui"
  172. ) else (
  173. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« en-US\lc.dll.mui"
  174. )
  175. ren "%consolepath%\ru-RU\lc.dll.mui" "lc.dll.mui%file_old_version%"
  176. if "%log_dir%" neq "" (
  177. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë ru-RU\lc.dll.mui"
  178. ) else (
  179. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« ru-RU\lc.dll.mui"
  180. )
  181. copy "%~dp0Module\x64\ru-RU\lc.dll.mui" "%consolepath%\ru-RU"
  182. if "%log_dir%" neq "" (
  183. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë ru-RU\lc.dll.mui"
  184. ) else (
  185. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« ru-RU\lc.dll.mui"
  186. )
  187. rem ‡ ¬¥­  ä ©«  á á®åà ­¥­¨¥¬ áâ à®© ¢¥àᨨ
  188. Setlocal EnableDelayedExpansion
  189. call :GetVersion "%consolepath%\Medusa.exe"
  190. Setlocal DisableDelayedExpansion
  191. ren "%consolepath%\Medusa.exe" "Medusa.exe%file_old_version%"
  192. if "%log_dir%" neq "" (
  193. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë Medusa.exe"
  194. ) else (
  195. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« Medusa.exe"
  196. )
  197. copy "%~dp0Module\x64\Medusa.exe" "%consolepath%"
  198. if "%log_dir%" neq "" (
  199. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë Medusa.exe"
  200. ) else (
  201. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« Medusa.exe"
  202. )
  203. ren "%consolepath%\en-US\Medusa.resources.dll" "Medusa.resources.dll%file_old_version%"
  204. if "%log_dir%" neq "" (
  205. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë en-US\Medusa.resources.dll"
  206. ) else (
  207. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« en-US\Medusa.resources.dll"
  208. )
  209. copy "%~dp0Module\x64\en-US\Medusa.resources.dll" "%consolepath%\en-US"
  210. if "%log_dir%" neq "" (
  211. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë en-US\Medusa.resources.dll"
  212. ) else (
  213. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« en-US\Medusa.resources.dll"
  214. )
  215. ren "%consolepath%\ru-RU\Medusa.resources.dll" "Medusa.resources.dll%file_old_version%"
  216. if "%log_dir%" neq "" (
  217. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë ru-RU\Medusa.resources.dll"
  218. ) else (
  219. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥­®¢ âì § ¬¥­ï¥¬ë© ä ©« ru-RU\Medusa.resources.dll"
  220. )
  221. copy "%~dp0Module\x64\ru-RU\Medusa.resources.dll" "%consolepath%\ru-RU"
  222. if "%log_dir%" neq "" (
  223. call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë ru-RU\Medusa.resources.dll"
  224. ) else (
  225. call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡­®¢«ñ­­ë© ä ©« ru-RU\Medusa.resources.dll"
  226. )
  227. exit /b
  228. rem ================================================================================
  229. :GetVersion
  230. set file_old_version=_
  231. set file_path=%1
  232. set file_double_path=!file_path:\\=\!
  233. set file_double_path=!file_double_path:\=\\!
  234. set file_full_ver=
  235. wmic datafile where name^=!file_double_path! get Version /value >nul 2>&1
  236. for /F "delims=" %%a in ('wmic datafile where name^=!file_double_path! get Version /value') do (
  237. set file_full_ver=!file_full_ver!%%a
  238. )
  239. set file_ver=
  240. for /F "tokens=3 delims=.," %%a in ("!file_full_ver!") do set file_ver=!file_ver!_%%a
  241. for /F "tokens=4 delims=.," %%a in ("!file_full_ver!") do set file_ver=!file_ver!_%%a
  242. set file_old_version=!file_ver!
  243. exit /b
  244. rem ================================================================================
  245. :CheckStatus
  246. if %errorlevel% neq 0 (
  247. if "%log_dir%" neq "" (
  248. chcp 1251 >nul 2>&1
  249. echo %~1 > "%log_dir%fail.%computername%.%userdomain%.patch_%SnPatchVersion%.log"
  250. chcp %codepage_old% >nul 2>&1
  251. ) else (
  252. color 0C
  253. echo.
  254. echo %~1
  255. echo.
  256. pause
  257. )
  258. exit
  259. )
  260. exit /b
  261. rem ================================================================================
  262. rem ‡ ¯ã᪠áªà¨¯â  á ¯®¢ë襭¨¥¬ (UAC)
  263. :Elevate
  264. set "vbsGetPrivileges=%temp%\SNgetPriv_%~n0.vbs"
  265. echo.
  266. echo **************************************
  267. echo Running as administrator
  268. echo **************************************
  269. echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
  270. echo args = "ELEV " >> "%vbsGetPrivileges%"
  271. echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
  272. echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
  273. echo Next >> "%vbsGetPrivileges%"
  274. echo args = "/c """ + "%~f0" + """ " + args >> "%vbsGetPrivileges%"
  275. echo UAC.ShellExecute "%SystemRoot%\system32\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  276. rem echo UAC.ShellExecute "%~f0", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  277. "%SystemRoot%\system32\WScript.exe" "%vbsGetPrivileges%" %*
  278. exit /b