123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- @echo off
- rem ================================================================================
- for %%a in ("%~dp0\.") do set "SnPatchVersion=%%~nxa"
- rem ================================================================================
- rem ‚�ˆŒ€�ˆ…!!! ’¥ªáâ á®®¡é¥¨© ¤«ï ¢ë¢®¤ ¢ ä ©« ᤥ« ¢ ª®¤¨à®¢ª¥ CP1251!
- rem ================================================================================
- rem ‘®åà 塞 ⥪ãéãî ª®¤®¢ãî áâà ¨æã
- for /f "tokens=2 delims=:" %%i in ('chcp') do (set codepage_old=%%i)
- set codepage_old=%codepage_old:~1,9%
- rem ================================================================================
- rem �஢¥àª «¨ç¨¥ ¯à ¢ ¤¬¨¨áâà â®à
- if '%1'=='ELEV' (shift /1 & goto Install)
- >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
- if %errorlevel% neq 0 (
- goto Elevate
- )
- :Install
- rem ================================================================================
- rem �ਠ«¨ç¨¨ ¯ à ¬¥âà íâ® ¤®«¦¥ ¡ëâì ª â «®£ ¤«ï «®£®¢ ãáâ ®ª¨ ¯ âç
- set log_dir=%~1
- if ^"%log_dir%^" neq "" (
- set fin=%log_dir:~-1%
- if "%fin%" neq "\" (set log_dir=%log_dir%\)
- )
- rem ================================================================================
- rem �®«ã票¥ ¯ã⥩
- rem �ãâì ¤«ï ª®á®«¨ ã¯à ¢«¥¨ï
- reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v ControlCenterDir > nul 2> nul
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïîëó÷èòü ïóòü óñòàíîâêè ïðîäóêòà"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯®«ãç¨âì ¯ãâì ãáâ ®¢ª¨ ¯à®¤ãªâ "
- )
- FOR /F "usebackq tokens=2,* skip=2" %%L IN (
- `reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v ControlCenterDir`
- ) DO SET consolepath=%%M
- if %consolepath:~-1% EQU \ set consolepath=%consolepath:~0,-1%
- rem �ã⨠á¨á⥬ëå ä ©«®¢
- set Sys32=%systemroot%\System32
- set SysWOW=%systemroot%\SysWOW64
- rem �ãâì ¤à ©¢¥à®¢
- rem set SysDrv=%systemroot%\System32\drivers
- rem ================================================================================
- rem Žá®¢ ï à ¡®â ¯® ãáâ ®¢ª¥ ¯ âç
- rem Ž¯¥à æ¨ï ¢ § ¢¨á¨¬®á⨠®â à §à冷áâ¨
- if "%PROCESSOR_ARCHITECTURE%"=="x86" (
- call :PatchX86
- ) else (
- call :PatchX64
- )
- rem ================================================================================
- if "%log_dir%" neq "" (
- chcp 1251 >nul 2>&1
- echo Ïàò÷ óñòàíîâëåí óñïåøíî > "%log_dir%success.%computername%.%userdomain%.patch_%SnPatchVersion%.log"
- chcp %codepage_old% >nul 2>&1
- ) else (
- color 0A
- echo � âç ãáâ ®¢«¥ ãᯥè®
- pause
- )
- exit /b
- rem ================================================================================
- :PatchX86
- rem ‡ ¬¥ ä ©« á á®åà ¥¨¥¬ áâ ன ¢¥àᨨ
- Setlocal EnableDelayedExpansion
- call :GetVersion "%consolepath%\lc.dll"
- Setlocal DisableDelayedExpansion
- ren "%consolepath%\lc.dll" "lc.dll%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë lc.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« lc.dll"
- )
- copy "%~dp0Module\win32\lc.dll" "%consolepath%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë lc.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« lc.dll"
- )
- ren "%consolepath%\en-US\lc.dll.mui" "lc.dll.mui%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë en-US\lc.dll.mui"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« en-US\lc.dll.mui"
- )
- copy "%~dp0Module\win32\en-US\lc.dll.mui" "%consolepath%\en-US"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë en-US\lc.dll.mui"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« en-US\lc.dll.mui"
- )
- ren "%consolepath%\ru-RU\lc.dll.mui" "lc.dll.mui%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë ru-RU\lc.dll.mui"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« ru-RU\lc.dll.mui"
- )
- copy "%~dp0Module\win32\ru-RU\lc.dll.mui" "%consolepath%\ru-RU"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë ru-RU\lc.dll.mui"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« ru-RU\lc.dll.mui"
- )
- rem ‡ ¬¥ ä ©« á á®åà ¥¨¥¬ áâ ன ¢¥àᨨ
- Setlocal EnableDelayedExpansion
- call :GetVersion "%consolepath%\Medusa.exe"
- Setlocal DisableDelayedExpansion
- ren "%consolepath%\Medusa.exe" "Medusa.exe%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë Medusa.exe"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« Medusa.exe"
- )
- copy "%~dp0Module\win32\Medusa.exe" "%consolepath%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë Medusa.exe"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« Medusa.exe"
- )
- ren "%consolepath%\en-US\Medusa.resources.dll" "Medusa.resources.dll%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë en-US\Medusa.resources.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« en-US\Medusa.resources.dll"
- )
- copy "%~dp0Module\win32\en-US\Medusa.resources.dll" "%consolepath%\en-US"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë en-US\Medusa.resources.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« en-US\Medusa.resources.dll"
- )
- ren "%consolepath%\ru-RU\Medusa.resources.dll" "Medusa.resources.dll%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë ru-RU\Medusa.resources.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« ru-RU\Medusa.resources.dll"
- )
- copy "%~dp0Module\win32\ru-RU\Medusa.resources.dll" "%consolepath%\ru-RU"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë ru-RU\Medusa.resources.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« ru-RU\Medusa.resources.dll"
- )
- exit /b
- rem ================================================================================
- :PatchX64
- rem ‡ ¬¥ ä ©« á á®åà ¥¨¥¬ áâ ன ¢¥àᨨ
- Setlocal EnableDelayedExpansion
- call :GetVersion "%consolepath%\lc.dll"
- Setlocal DisableDelayedExpansion
- ren "%consolepath%\lc.dll" "lc.dll%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë lc.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« lc.dll"
- )
- copy "%~dp0Module\x64\lc.dll" "%consolepath%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë lc.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« lc.dll"
- )
- ren "%consolepath%\en-US\lc.dll.mui" "lc.dll.mui%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë en-US\lc.dll.mui"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« en-US\lc.dll.mui"
- )
- copy "%~dp0Module\x64\en-US\lc.dll.mui" "%consolepath%\en-US"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë en-US\lc.dll.mui"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« en-US\lc.dll.mui"
- )
- ren "%consolepath%\ru-RU\lc.dll.mui" "lc.dll.mui%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë ru-RU\lc.dll.mui"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« ru-RU\lc.dll.mui"
- )
- copy "%~dp0Module\x64\ru-RU\lc.dll.mui" "%consolepath%\ru-RU"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë ru-RU\lc.dll.mui"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« ru-RU\lc.dll.mui"
- )
- rem ‡ ¬¥ ä ©« á á®åà ¥¨¥¬ áâ ன ¢¥àᨨ
- Setlocal EnableDelayedExpansion
- call :GetVersion "%consolepath%\Medusa.exe"
- Setlocal DisableDelayedExpansion
- ren "%consolepath%\Medusa.exe" "Medusa.exe%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë Medusa.exe"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« Medusa.exe"
- )
- copy "%~dp0Module\x64\Medusa.exe" "%consolepath%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë Medusa.exe"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« Medusa.exe"
- )
- ren "%consolepath%\en-US\Medusa.resources.dll" "Medusa.resources.dll%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë en-US\Medusa.resources.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« en-US\Medusa.resources.dll"
- )
- copy "%~dp0Module\x64\en-US\Medusa.resources.dll" "%consolepath%\en-US"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë en-US\Medusa.resources.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« en-US\Medusa.resources.dll"
- )
- ren "%consolepath%\ru-RU\Medusa.resources.dll" "Medusa.resources.dll%file_old_version%"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ïåðåèìåíîâàòü çàìåíÿåìûé ôàéë ru-RU\Medusa.resources.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ¯¥à¥¨¬¥®¢ âì § ¬¥ï¥¬ë© ä ©« ru-RU\Medusa.resources.dll"
- )
- copy "%~dp0Module\x64\ru-RU\Medusa.resources.dll" "%consolepath%\ru-RU"
- if "%log_dir%" neq "" (
- call :CheckStatus "[ÎØÈÁÊÀ] Íå óäàëîñü ñêîïèðîâàòü îáíîâë¸ííûé ôàéë ru-RU\Medusa.resources.dll"
- ) else (
- call :CheckStatus "[Ž˜ˆ�Š€] �¥ 㤠«®áì ᪮¯¨à®¢ âì ®¡®¢«ñë© ä ©« ru-RU\Medusa.resources.dll"
- )
- exit /b
- rem ================================================================================
- :GetVersion
- set file_old_version=_
- set file_path=%1
- set file_double_path=!file_path:\\=\!
- set file_double_path=!file_double_path:\=\\!
- set file_full_ver=
- wmic datafile where name^=!file_double_path! get Version /value >nul 2>&1
- for /F "delims=" %%a in ('wmic datafile where name^=!file_double_path! get Version /value') do (
- set file_full_ver=!file_full_ver!%%a
- )
- set file_ver=
- for /F "tokens=3 delims=.," %%a in ("!file_full_ver!") do set file_ver=!file_ver!_%%a
- for /F "tokens=4 delims=.," %%a in ("!file_full_ver!") do set file_ver=!file_ver!_%%a
- set file_old_version=!file_ver!
- exit /b
- rem ================================================================================
- :CheckStatus
- if %errorlevel% neq 0 (
- if "%log_dir%" neq "" (
- chcp 1251 >nul 2>&1
- echo %~1 > "%log_dir%fail.%computername%.%userdomain%.patch_%SnPatchVersion%.log"
- chcp %codepage_old% >nul 2>&1
- ) else (
- color 0C
- echo.
- echo %~1
- echo.
- pause
- )
- exit
- )
- exit /b
- rem ================================================================================
- rem ‡ ¯ã᪠áªà¨¯â á ¯®¢ë襨¥¬ (UAC)
- :Elevate
- set "vbsGetPrivileges=%temp%\SNgetPriv_%~n0.vbs"
- echo.
- echo **************************************
- echo Running as administrator
- echo **************************************
- echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
- echo args = "ELEV " >> "%vbsGetPrivileges%"
- echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
- echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
- echo Next >> "%vbsGetPrivileges%"
- echo args = "/c """ + "%~f0" + """ " + args >> "%vbsGetPrivileges%"
- echo UAC.ShellExecute "%SystemRoot%\system32\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
- rem echo UAC.ShellExecute "%~f0", args, "", "runas", 1 >> "%vbsGetPrivileges%"
- "%SystemRoot%\system32\WScript.exe" "%vbsGetPrivileges%" %*
- exit /b
|