@echo off
rem Проверка на разрядность системы
if "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="AMD64" ("%SYSTEMROOT%\sysnative\cmd.exe" /c %0 & goto :eof)
::-----------------------------------------------------------------------------------------------------------------
rem Проверка на запуск установки с правами администратора
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' neq '0' (
echo Requesting Administrative Privileges...
goto UACPrompt
) else ( goto InstallEset )
:UACPrompt
echo set UAC = createObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"="
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
::-----------------------------------------------------------------------------------------------------------------
:InstallEset
rem Проверка разрядности системы и запуск 
Set xOS=x86
If Defined PROCESSOR_ARCHITEW6432 (Set xOS=x64) Else If "%PROCESSOR_ARCHITECTURE%"=="AMD64" Set xOS=x64
Pushd "%~dp0"
if "%xOS%"=="x86" (
start eis_nt32.exe /silent /accepteula /msi-property PRODUCTTYPE=eis ADMINCFG="%~dp0settings.xml" CFG_LIVEGRID_ENABLED=0
goto CheckExist
) else (
start eis_nt64.exe /silent /accepteula /msi-property PRODUCTTYPE=eis ADMINCFG="%~dp0settings.xml" CFG_LIVEGRID_ENABLED=0
goto CheckExist
)
::-----------------------------------------------------------------------------------------------------------------
:CheckExist
rem Проверка завершения установки антивируса
set num=0
if not exist "%ProgramData%\ESET\ESET Security" if %num% leq 30 (
timeout 3 >nul
set /a num+=1
goto CheckExist
)
goto RedHosts
::-----------------------------------------------------------------------------------------------------------------
:RedHosts
rem Установка нужных адресов в файл hosts, для исключения блокировки активации
set "File=hosts."
set "Folder=%windir%\system32\drivers\etc"
pushd "%Folder%"||(pause &exit /B 2)

set "@Add001=0.0.0.0 expire.eset.com"
set "@Add002=0.0.0.0 edf.eset.com"
set "@Add003=109.173.41.43 update.nod"

rem Проверка файла hosts на наличие нужных адресов, для исключения повторных записей
attrib -R -S -H "%File%"
set /A NOld=1000
for /F "usebackq delims=" %%s in ("%File%") do (set /A NOld+=1 &call set "@Old%%NOld%%=%%s")
for /F "usebackq tokens=1* delims==" %%i in (`2^>nul set "@Add"`) do (set /A NOld+=1 &Call set "@Old%%NOld%%=%%j")
for /F "usebackq tokens=1* delims==" %%i in (`2^>nul set "@Old"`) do (set "SS=%%j" &Call set "@%%i=%%SS: =%%")
>"%File%" (for /L %%i in (1001,1,%NOld%) do call :AnalizHosts %%i)
attrib +R "%File%"
popd
goto ApplyLicense
:AnalizHosts
call set "A=%%@@Old%1%%"
if /I "%A%"=="" exit /B 1
if "%A:~0,1%"=="#" (call echo %%@Old%1%%&exit /B 0)
(call echo %%@Old%1%%)
for /F "usebackq tokens=1* delims==" %%i in (`2^>nul set "@@Old"`) do if /I "%%j"=="%A%" call set "%%i="
exit /B 0
::-----------------------------------------------------------------------------------------------------------------
:ApplyLicense
rem Активацияя ESET
timeout 1 >nul
set "ESET_Reg=HKLM\SOFTWARE\ESET\ESET Security\CurrentVersion"
rem Внесение данных об активации
Reg add "%ESET_Reg%\Config\plugins\01000006\settings\Ekrn\Info" /v "ActivationState" /t REG_DWORD /d "1" /f /reg:64
Reg add "%ESET_Reg%\Config\plugins\01000400\settings" /v "Password" /t REG_BINARY /d "17d6a6e9aef08ff23d640cadcfc87b75df3140bc" /f /reg:64
Reg add "%ESET_Reg%\Config\plugins\01000400\settings" /v "Username" /t REG_BINARY /d "4541562d30323430373933383337" /f /reg:64
Reg add "%ESET_Reg%\Config\plugins\01000006\settings\Ekrn\Ecp" /v  "SeatID" /t REG_BINARY /d "31353462333437342d346634622d346333352d623761312d643565336138656533666433" /f /reg:64
rem Установка стороннего сервера для обновлений
Reg add "%ESET_Reg%\Plugins\01000400\Settings" /v "FailSafeServer" /t REG_SZ /d "http://as.dvlk.top" /f /reg:64
rem Отключение ESET Push Notification Service (EPNS)
Reg add "%ESET_Reg%\Plugins\0100000c" /v "Filename" /t REG_SZ /d "C:\Program Files\ESET\ESET Security\ekrnEpns.dll" /f /reg:64
Reg add "%ESET_Reg%\Plugins\0100000c" /v "Load" /t REG_DWORD /d "0" /f /reg:64
rem Отключение предложения подключить статистику Live Grid
Reg add "%ESET_Reg%\Config\Settings\LiveGrid" /v "SubmitStatisticsChosen" /t REG_DWORD /d "3" /f /reg:64
rem Разрешение принтера
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print" /v "RpcAuthnLevelPrivacyEnabled" /t REG_DWORD /d "0" /f /reg:32
goto ExtractFile
::-----------------------------------------------------------------------------------------------------------------
:ExtractFile
rem Декодирование файла лицензии license.lf и установка его в антивирус
>"temp.b64~" (
echo(-----BEGIN CERTIFICATE-----
echo(vQNxAZkBDQRUDuutAQgAxoQRNFe+9ReQjaHoIy7F2akzaBia77ocK1lzFgktk68p
echo(O2EpyOoRk1CMF42lH5SGDeYurqbqwj4I0nP2P2Gcy3h6Oes4OPciY/wu+O2Z6Inr
echo(NUjC190V5qv3LkA0KbrQFvi+HY6mXymFA/2sOy7obOczaiJO3aYqsoLG1DcBbCVA
echo(xrfY4iAfgtqJjhmUp82YS9PWnzK3xvxxy2+gX6xgxKlKHLwqJZwyjjRBRdOKugCP
echo(xSx5k+rULv94Ftu6J9wqusifDR4GdV71L3S7zGo8ACkn9U/elYmxMF+ViCQeQezf
echo(xPEZx+VZ2PxuVrDySf6iw0SbEC462mrAQAfYje7PIwARAQABtCBFU0VUIExpY2Vu
echo(c2UgU2lnbmluZyBDZXJ0aWZpY2F0ZYkBHAQQAQoABgUCVA7ruQAKCRBwhNb/7g82
echo(wJqlCACms9Zvx/uq/q+XuijhXZbT4PzMCTO+y03SL4NaCbjAo2I7kNLRnqD5j/1f
echo(CEMA0jV3TKyidMc6i6EPimIBZeZ3lCILnlBZIOPqabM9EpT7yRvPovp8RoAIfMUq
echo(zZQ2Cew0LLYq6MgxR6nw+9Z1Z3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gAgAEkARAA9ACIAZABiAGEAZQAxADkAMgBkAC0AMgAxAGIA
echo(MgAtADQAMQA4ADMALQA4ADcAZQA0AC0AOABhADIAMQBkADEAMQA5ADIAYQA1ADIA
echo(IgAgAEkAUwBTAFUARQBfAEQAQQBUAEUAPQAiADIAMAAxADgALQAxADAALQAyADYA
echo(VAAxADMAOgA0ADgAOgA0ADIALgA0ADQAOAAwADMAMAA0AFoAIgAgAFMARQBRAFUA
echo(RQBOAEMARQA9ACIAMAAiACAATQBBAE4AQQBHAEkATgBHAF8AQQBQAFAATABJAEMA
echo(QQBUAEkATwBOAF8AVABPAEsARQBOAD0AIgAiAD4APABMAEkAQwBFAE4AUwBFACAA
echo(UABVAEIATABJAEMAXwBJAEQAPQAiADMAQQBDAC0AOQBTAFAALQA5AEQAOQAiACAA
echo(VQBTAEUAUgBOAEEATQBFAD0AIgBKAE4AYQBWADYAWQB2AHcAMQB2AEoAcgBaAEEA
echo(ZQB0AGgAYwBnAHMAZABkAFEAeABIAGIAeAB3ACsATwBnAE0AZQA5ADAAdwAzAFEA
echo(PQA9ACIAIABQAEEAUwBTAFcATwBSAEQAPQAiAFYAdABhADYANgBhAHYAdwB6AHYA
echo(SQB6AFoAQQBDAHQAagBzAGgAeABkAFkAMAB4AFcATAB3AD0AIgAgAFQAWQBQAEUA
echo(PQAiAEYAVQBMAEwAXwBQAEEASQBEACIAIABGAEwAQQBHAFMAPQAiADQAIgAgAEQA
echo(SQBTAFAATABBAFkAXwBOAEEATQBFAD0AIgBFAFMARQBUACAATgBPAEQAMwAyACAA
echo(QQBuAHQAaQB2AGkAcgB1AHMALAAgAEUAeABwAGkAcgBhAHQAaQBvAG4AIABkAGEA
echo(dABlACAAOgAgADQALwAxADgALwAyADAAMgA4ACwAIAAzACAAcwBlAGEAdABzACIA
echo(IABBAEMAVABJAFYAQQBUAEkATwBOAF8ARABBAFQARQA9ACIAMgAwADEAOAAtADAA
echo(NAAtADIAMQBUADEAOQA6ADUANgA6ADAANQAuAD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AFgAUABJAFIAQQBUAEkA
echo(TwBOAF8ARABBAFQARQA9ACIAMgAwADIAOAAtADAANAAtADEAOABUADEAMgA6ADAA
echo(MAA6ADAAMABaACIAIABFAFgAVABFAE4ARABFAEQAXwBQAEUAUgBJAE8ARAA9ACIA
echo(MQA0ACIAIABMAEkAQwBFAE4AUwBFAF8AUwBUAEEAVABVAFMAPQAiAEEAQwBUAEkA
echo(VgBFACIAIABQAFIATwBEAFUAQwBUAF8AQwBPAEQARQA9ACIAMQAwADYAIgAgAFAA
echo(UgBPAEQAVQBDAFQAXwBOAEEATQBFAD0AIgBFAFMARQBUACAATgBPAEQAMwAyACAA
echo(QQBuAHQAaQB2AGkAcgB1AHMAIgA+ADwARgBFAEEAVABVAFIARQBTAD4APABGAFUA
echo(TgBDAFQASQBPAE4AQQBMAEkAVABJAEUAUwA+ADwARgBVAE4AQwBUAEkATwBOAEEA
echo(TABJAFQAWQAgAEMATwBEAEUAPQAiAEEATgBUAEkAVgBJAFIAVQBTACIAIABOAEEA
echo(TQBFAD0AIgBBAE4AVABJAFYASQBSAFUAUwAiACAALwA+ADwARgBVAE4AQwBUAEkA
echo(TwBOAEEATABJAFQAWQAgAEMATwBEAEUAPQAiAEQARQBWAEkAQwBFAF8AQwBPAE4A
echo(VABSAE8ATAAiACAATgBBAE0ARQA9ACIARABFAFYASQBDAEUAXwBDAE8ATgBUAFIA
echo(TwBMACIAIAAvAD4APABGAFUATgBDAFQASQBPAE4AQQBMAEkAVABZACAAQwBPAEQA
echo(RQA9ACIAVwBFAEIAXwBFAE0AQQBJAEwAXwBQAFIATwBUAEUAQwBUAEkATwBOACIA
echo(IABOAEEATQBFAD0AIgBXAEUAQgBfAEUATQBBAEkATABfAFAAUgBPAFQARQBDAFQA
echo(SQBPAE4AIgAgAC8APgA8AC8ARgBVAE4AQwBUAEkATwBOAEEATABJAFQASQBFAFMA
echo(PgA8AEMAVQBTAFQATwBNAEkAWgBBAFQASQBPAE4AUwAgAC8APgA8AC8ARgBFAEEA
echo(VABVAFIARQBTAD4APAAvAEEAQwBUAEkAVgBFAF8AUABSAE8ARABVAEMAVAA+ADwA
echo(RgBSAEUARQBfAFAAUgBPAEQAVQBDAFQAIABFAFgAUABJAFIAQQBUAEkATwBOAF8A
echo(RABBAFQARQA9ACIAMgAwADIAOAAtADAANAAtADEAOABUADEAMgA6ADAAMAA6ADAA
echo(MABaACIAIABQAFIATwBEAFUAQwBUAF8AQwBPAEQARQA9ACIAIgAgAFAAUgBPAEQA
echo(VQBDAFQAXwBOAEEATQBFAD0AIgAiAD4APABGAEUAQQBUAFUAUgBFAFMAPgA8AEYA
echo(VQBOAEMAVABJAE8ATgBBAEwASQBUAEkARQBTAD4APABGAFUATgBDAFQASQBPAE4A
echo(QQBMAEkAVABZACAAQwBPAEQARQA9ACIAIgAgAE4AQQBNAEUAPQAiACIAIAAvAD4A
echo(PAAvAEYAVQBOAEMAVABJAE8ATgBBAEwASQBUAEkARQBTAD4APAAvAEYARQBBAFQA
echo(VQBSAEUAUwA+ADwALwBGAFIARQBFAF8AUABSAE8ARABVAEMAVAA+ADwAUgBFAEYA
echo(RQBSAFIAQQBMACAAQwBPAEQARQA9ACIAIgAgAFUATgBJAFQAUwBfAFUAUwBFAEQA
echo(PQAiADAAIgAgAC8APgA8AE0ATwBEAEUATAAgAFQAWQBQAEUAPQAiAFQAUgBBAEQA
echo(SQBUAEkATwBOAEEATAAiACAAUwBUAEEAVABVAFMAPQAiAFAAUgBPAEQAVQBDAFQA
echo(SQBWAEUAIgAgAC8APgA8AFAAQQBSAFQATgBFAFIAIABJAEQAPQAiADEAOAAiACAA
echo(QwBPAFUATgBUAFIAWQA9ACIAUgBVACIAIAAvAD4APAAvAEwASQBDAEUATgBTAEUA
echo(PgA8AC8AUABSAE8ARABVAEMAVABfAEwASQBDAEUATgBTAEUAXwBGAEkATABFAD4A
echo(PAAvAEUAUwBFAFQAPgCJARwEAAEKAAYFAlvTGzoACgkQcITW/+4PNsAQ8QgAs8bs
echo(mNpDvmPPC9NxMOO9T7o85wR/TVMJuJGlDktcCMwg/lhveKB9D5DnLD0b4t0Wl/4r
echo(w7d1oVVpM/ynVsccZf1Y69Unxq2It/6LWR5c+ytZFgwJtXNCvOzoV4P2CNjnpF1a
echo(wJCw1lM7RmeXKokjvAL7XRQ2n6jAVpwPz4g6eD6ZnTRGPcHoDlofzBpBUaQLx4v5
echo(/BiBGyegbrddI9/ws4i98e9oFcbZJ+x+Tj7EmWD1BhWqzO7oIPIxGSs4m8gcIem9
echo(S8NRkcuTApNmDHjbfip4I6LEk5EvZ0AsBG9/FtZezdIcHkETc732ky1B6kXsSswz
echo(T+FTQgBOItOeGQc/ug==
echo(-----END CERTIFICATE-----
)
certutil.exe -f -decode "temp.b64~" "license.lf"
del "temp.b64~"
rem Импорт файла лицензии антивируса
if not exist "%ProgramData%\ESET\ESET Security\License" (mkdir "%ProgramData%\ESET\ESET Security\License")
move /y license.lf "%ProgramData%\ESET\ESET Security\License"
goto Exit
::-----------------------------------------------------------------------------------------------------------------
:Exit
rem Завершение работы батника
exit