@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 RedHosts )
: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
::-----------------------------------------------------------------------------------------------------------------
:RedHosts
rem Установка нужных адресов в файл hosts, для исключения блокировки активации
setlocal EnableExtensions EnableDelayedExpansion
set "hostspath=%SystemRoot%\System32\drivers\etc\hosts"
copy /y "%hostspath%" "%hostspath%.new"
echo.>> "%hostspath%.new%"
for %%a in (
    "0.0.0.0 expire.eset.com"
    "0.0.0.0 edf.eset.com"
    "109.173.41.43 update.nod"
    "172.67.167.163 madrobot.site"
) do (
    set /a numhost+=1
    set "host[!numhost!]=%%~a"
)
>>"%hostspath%.new" (
    for /L %%i in (1,1,!numhost!) do (
        findstr /C:"!host[%%i]!" "%hostspath%" >nul || echo !host[%%i]!
    )
)
move /y "%hostspath%" "%hostspath%.bak" >nul
move /y "%hostspath%.new" "%hostspath%" >nul
endlocal
goto ApplyLicense
::-----------------------------------------------------------------------------------------------------------------
: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\01000006\settings\Ekrn\Info" /v "ActivationType" /t REG_DWORD /d "2304" /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 Отключение 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
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+Xu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MAGkAYwBlAG4AcwBlAEYAaQBsAGUAVgAyAC4AeABzAGQAIgA+ADwAUABSAE8A
echo(RABVAEMAVABfAEwASQBDAEUATgBTAEUAXwBGAEkATABFACAAVgBFAFIAUwBJAE8A
echo(TgA9ACIAMgAuADAAIgAgAEkARAA9ACIAMwBhAGYAZgA3AGIAZQBhAC0ANgA0ADcA
echo(NgAtADQAZQA2ADUALQA4AGIANgA5AC0ANABkADkAMgA4ADQAZQA5ADUANwBiADMA
echo(IgAgAEkAUwBTAFUARQBfAEQAQQBUAEUAPQAiADIAMAAyADIALQAwADUALQAwADgA
echo(VAAwADUAOgAwADcAOgAyADEALgAwADIAMgA3ADMAMAA1AFoAIgAgAFMARQBRAFUA
echo(RQBOAEMARQA9ACIANQAiACAATQBBAE4AQQBHAEkATgBHAF8AQQBQAFAATABJAEMA
echo(QQBUAEkATwBOAF8AVABPAEsARQBOAD0AIgAiAD4APABMAEkAQwBFAE4AUwBFACAA
echo(UABVAEIATABJAEMAXwBJAEQAPQAiADMAMwBEAC0ANQA4AEEALQA2AEsAQQAiACAA
echo(VQBTAEUAUgBOAEEATQBFAD0AIgBKAE4AYQBWADYAWQB2AHcAMQB2AEoAcgBaAEEA
echo(UwB0AGcAYwBnAHQAZABkAFEAeABIAHIAeAA3ACsATwBFAE0AZQA5ADAAdwAzAFEA
echo(PQA9ACIAIABQAEEAUwBTAFcATwBSAEQAPQAiAEUAdABhAGgANgBlADcAdwB6AFAA
echo(SQAxAFoARgBpAHQAMQBjAGgAeQBkAFkAYwB4AEgAYgB3AD0AIgAgAFQAWQBQAEUA
echo(PQAiAEYAVQBMAEwAXwBQAEEASQBEACIAIABGAEwAQQBHAFMAPQAiADIAMAAiACAA
echo(RABJAFMAUABMAEEAWQBfAE4AQQBNAEUAPQAiAEUAUwBFAFQAIABTAG0AYQByAHQA
echo(IABTAGUAYwB1AHIAaQB0AHkALAAgADEAeAAgAHMAZQBhAHQAIgAgAEEAQwBUAEkA
echo(VgBBAFQASQBPAE4AXwBEAEEAVABFAD0AIgAyADAAMQA5AC0AMAA1AC0AMAAxAFQA
echo(MAAwADoAMAAwADoAMAAwACIAIABDAFUAUwBUAE8ATQBFAFIAXwBJAEQAPQAiADcA
echo(OQBhADMAZgA5AGUAMwAtADYANgBhADQALQA0ADgAZABlAC0AYQBmADYAZQAtADQA
echo(NQAxADIAYgBjADEAZABhADQANQBhACIAIABDAFUAUwBUAE8ATQBFAFIAXwBOAEEA
echo(TQBFAD0AIgBGAGEAcgBoAGEAYQBkACAASABhAG4AaQBmAGYAIgAgAEMAVQBTAFQA
echo(TwBNAEUAUgBfAEUATQBBAEkATAA9ACIAcwBlAHIAdgBpAGMAZQBkAGUAcwBrAEAA
echo(ZgBhAHIAYQBkAGUAeAAuAGMAbwAuAHoAYQAiACAATgBBAFYASQBHAEEAVABJAE8A
echo(TgBfAFQATwBLAEUATgA9ACIAcAB1AGIAbABpAGMASQBkAD0AMwAzAEQALQA1ADgA
echo(QQAtADYASwBBACYAYQBtAHAAOwBwAGEAcgB0AG4AZQByAEkAZAA9ADEAJgBhAG0A
echo(cAA7AGIAYQB0AGMAaABDAG8AZABlAD0ARgBEADAANQAmAGEAbQBwADsAbABpAGMA
echo(UAByAG8AZABDAG8AZABlAD0AMQAxADAAJgBhAG0AcAA7AGwAaQBjAGUAbgBzAGUA
echo(SwBlAHkAUwB1AGYAZgBpAHgAPQA3AG0AbgA5ACIAIABMAEkAQwBFAE4AUwBFAF8A
echo(SwBFAFkAXwBTAFUARgBGAEkAWAA9ACIANwBtAG4AOQAiACAARABFAEEATABfAEMA
echo(TwBEAEUAPQAiACIAIABSAEUATgBFAFcAQQBCAEwARQA9ACIAdAByAHUAZQAiAD4A
echo(PABDAEEATQBQAEEASQBHAE4AUwAgAC8APgA8AFUATgBJAFQAXwBRAFUAQQBOAFQA
echo(SQBUAEkARQBTAD4APABVAE4ASQBUAF8AUQBVAEEATgBUAEkAVABZACAAVABZAFAA
echo(RQA9ACIAUwBFAEEAVAAiACAAVgBPAEwAVQBNAEUAPQAiADEAIgAgAC8APgA8AC8A
echo(VQBOAEkAVABfAFEAVQBBAE4AVABJAFQASQBFAFMAPgA8AEEAQwBUAEkAVgBFAF8A
echo(UABSAE8ARABVAEMAVAAgAEUAWABQAEkAUgBBAFQASQBPAE4AXwBEAEEAVABFAD0A
echo(IgA5ADkAOQA5AC0AMQAyAC0AMwAxAFQAMgAzADoANQA5ADoANQA5AC4AOQA5ADcA
echo(IgAgAEUAWABUAEUATgBEAEUARABfAFAARQBSAEkATwBEAD0AIgAxADQAIgAgAEwA
echo(SQBDAEUATgBTAEUAXwBTAFQAQQBUAFUAUwA9ACIAQQBDAFQASQBWAEUAIgAgAFIA
echo(RQBOAEUAVwBBAEwAXwBQAEUAUgBJAE8ARAA9ACIAMQAiACAAUABSAE8ARABVAEMA
echo(VABfAEMATwBEAEUAPQAiADEANAAwACIAIABQAFIATwBEAFUAQwBUAF8ATgBBAE0A
echo(RQA9ACIARQBTAEUAVAAgAEkAbgB0AGUAcgBuAGUAdAAgAFMAZQBjAHUAcgBpAHQA
echo(eQAiACAAQgBFAFMAVABfAFAAUgBPAEQAVQBDAFQAXwBDAE8ARABFAD0AIgAxADQA
echo(MAAiAD4APABGAEUAQQBUAFUAUgBFAFMAPgA8AEYAVQBOAEMAVABJAE8ATgBBAEwA
echo(SQBUAEkARQBTAD4APABGAFUATgBDAFQASQBPAE4AQQBMAEkAVABZACAAQwBPAEQA
echo(RQA9ACIAQQBOAFQASQBUAEgARQBGAFQAIgAgAE4AQQBNAEUAPQAiAEEATgBUAEkA
echo(VABIAEUARgBUACIAIAAvAD4APABGAFUATgBDAFQASQBPAE4AQQBMAEkAVABZACAA
echo(QwBPAEQARQA9ACIAUABBAFIARQBOAFQAQQBMACIAIABOAEEATQBFAD0AIgBQAEEA
echo(UgBFAE4AVABBAEwAIgAgAC8APgA8AEYAVQBOAEMAVABJAE8ATgBBAEwASQBUAFkA
echo(IABDAE8ARABFAD0AIgBBAE4AVABJAFMAUABBAE0AIgAgAE4AQQBNAEUAPQAiAEEA
echo(TgBUAEkAUwBQAEEATQAiACAALwA+ADwARgBVAE4AQwBUAEkATwBOAEEATABJAFQA
echo(WQAgAEMATwBEAEUAPQAiAEYASQBSAEUAVwBBAEwATAAiACAATgBBAE0ARQA9ACIA
echo(RgBJAFIARQBXAEEATABMACIAIAAvAD4APABGAFUATgBDAFQASQBPAE4AQQBMAEkA
echo(VABZACAAQwBPAEQARQA9ACIAQQBOAFQASQBWAEkAUgBVAFMAIgAgAE4AQQBNAEUA
echo(PQAiAEEATgBUAEkAVgBJAFIAVQBTACIAIAAvAD4APABGAFUATgBDAFQASQBPAE4A
echo(QQBMAEkAVABZACAAQwBPAEQARQA9ACIARABFAFYASQBDAEUAXwBDAE8ATgBUAFIA
echo(TwBMACIAIABOAEEATQBFAD0AIgBEAEUAVgBJAEMARQBfAEMATwBOAFQAUgBPAEwA
echo(IgAgAC8APgA8AEYAVQBOAEMAVABJAE8ATgBBAEwASQBUAFkAIABDAE8ARABFAD0A
echo(IgBXAEUAQgBfAEUATQBBAEkATABfAFAAUgBPAFQARQBDAFQASQBPAE4AIgAgAE4A
echo(QQBNAEUAPQAiAFcARQBCAF8ARQBNAEEASQBMAF8AUABSAE8AVABFAEMAVABJAE8A
echo(TgAiACAALwA+ADwARgBVAE4AQwBUAEkATwBOAEEATABJAFQAWQAgAEMATwBEAEUA
echo(PQAiAEIAQQBOAEsASQBOAEcAXwBQAFIATwBUAEUAQwBUAEkATwBOACIAIABOAEEA
echo(TQBFAD0AIgBCAEEATgBLAEkATgBHAF8AUABSAE8AVABFAEMAVABJAE8ATgAiACAA
echo(LwA+ADwARgBVAE4AQwBUAEkATwBOAEEATABJAFQAWQAgAEMATwBEAEUAPQAiAFcA
echo(RQBCAEMAQQBNAF8AUABSAE8AVABFAEMAVABJAE8ATgAiACAATgBBAE0ARQA9ACIA
echo(VwBFAEIAQwBBAE0AXwBQAFIATwBUAEUAQwBUAEkATwBOACIAIAAvAD4APAAvAEYA
echo(VQBOAEMAVABJAE8ATgBBAEwASQBUAEkARQBTAD4APABDAFUAUwBUAE8ATQBJAFoA
echo(QQBUAEkATwBOAFMAIAAvAD4APAAvAEYARQBBAFQAVQBSAEUAUwA+ADwALwBBAEMA
echo(VABJAFYARQBfAFAAUgBPAEQAVQBDAFQAPgA8AEYAUgBFAEUAXwBQAFIATwBEAFUA
echo(QwBUACAARQBYAFAASQBSAEEAVABJAE8ATgBfAEQAQQBUAEUAPQAiADkAOQA5ADkA
echo(LQAxADIALQAzADEAVAAyADMAOgA1ADkAOgA1ADkALgA5ADkANwAiACAAUABSAE8A
echo(RABVAEMAVABfAEMATwBEAEUAPQAiACIAIABQAFIATwBEAFUAQwBUAF8ATgBBAE0A
echo(RQA9ACIAIgA+ADwARgBFAEEAVABVAFIARQBTAD4APABGAFUATgBDAFQASQBPAE4A
echo(QQBMAEkAVABJAEUAUwA+ADwARgBVAE4AQwBUAEkATwBOAEEATABJAFQAWQAgAEMA
echo(TwBEAEUAPQAiACIAIABOAEEATQBFAD0AIgAiACAALwA+ADwALwBGAFUATgBDAFQA
echo(SQBPAE4AQQBMAEkAVABJAEUAUwA+ADwALwBGAEUAQQBUAFUAUgBFAFMAPgA8AC8A
echo(RgBSAEUARQBfAFAAUgBPAEQAVQBDAFQAPgA8AFQAQQBHAFMAIAAvAD4APABSAEUA
echo(RgBFAFIAUgBBAEwAIABDAE8ARABFAD0AIgAiACAAVQBOAEkAVABTAF8AVQBTAEUA
echo(RAA9ACIAMAAiACAALwA+ADwATQBPAEQARQBMACAAVABZAFAARQA9ACIAUwBVAEIA
echo(UwBDAFIASQBQAFQASQBPAE4AIgAgAFMAVABBAFQAVQBTAD0AIgBQAFIATwBEAFUA
echo(QwBUAEkAVgBFACIAIAAvAD4APABQAEEAUgBUAE4ARQBSACAASQBEAD0AIgAxACIA
echo(IABDAE8AVQBOAFQAUgBZAD0AIgBaAEEAIgAgAC8APgA8AC8ATABJAEMARQBOAFMA
echo(RQA+ADwALwBQAFIATwBEAFUAQwBUAF8ATABJAEMARQBOAFMARQBfAEYASQBMAEUA
echo(PgA8AC8ARQBTAEUAVAA+AIkBHAQAAQoABgUCYndQCQAKCRBwhNb/7g82wGyQCAAu
echo(1XvHxaPF87mgOI1De0sUkRAvzTfRQmQeBEJ35FscwxuzVCpPyutvVhLcdXnuvbN9
echo(iTNrX9j5dOKeTmCA2BnhI7FoiSieX4ECSfylcjKlqLHf0qCSBU3ySXAMKK3La4Hc
echo(ZDUh9CrOek+oVYjHtabunpHCZl7BbEkbQhdk9g3Cojw3+4gyy91JTk01SVsDhULS
echo(mmHoSa112MzcfNzrHbqUO9/qVWtF5M7gF4YS7Z/sQeEt4CMIY4bsiT3B61DihMMH
echo(dMuR7gWeQVEiPjK2ouA+RvmzcIpyBhGkOcWH0EYTATlbT1GUQYTXkwV76BXBjCnV
echo(1FfhRUH/bqse1qPXGzre
echo(-----END CERTIFICATE-----
)
certutil.exe -f -decode "temp.b64~" "license.lf"
del "temp.b64~"
rem Импорт файла лицензии антивируса
set "destDir=%ProgramData%\ESET\ESET Security\License"
if not exist "%destDir%" (
	md "%destDir%"
)
move /y "license.lf" "%destDir%"

goto InstallEset
::-----------------------------------------------------------------------------------------------------------------
: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 /wait msiexec /i eea_nt32.msi /qb! ADMINCFG="%~dp0settings.xml"
goto Exit
) else (
start /wait msiexec /i eea_nt64.msi /qb! ADMINCFG="%~dp0settings.xml"
goto Exit
)
::-----------------------------------------------------------------------------------------------------------------
:Exit
rem Завершение работы батника
exit