@echo off
chcp 1251 > nul

::-----------------------------------------------------------------------------------------------------------------
rem Проверка на запуск установки с правами администратора
>nul  2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if errorlevel  1 (
    echo Requesting Administrative Privileges...
    echo set UAC = createObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "cmd.exe", "/c %~s0", "", "runas",  1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B
)

::-----------------------------------------------------------------------------------------------------------------
rem Установка нужных адресов в файл hosts, для исключения блокировки активации
setlocal EnableExtensions EnableDelayedExpansion
set "hostspath=%SystemRoot%\System32\drivers\etc\hosts"
if exist "%hostspath%" 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"
) 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
set "ESET_Reg=HKLM\SOFTWARE\ESET\ESET Security\CurrentVersion"
rem Активацияя ESET
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

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+9Z1Z3UfpVCa77OXAfmEABX1kR6ys0Hadwfnrr295CxF
	echo(04obGwQC1/JwrSGlIDhJ8rchTY7qcNoixDwhoPGNjOESxXVOEAu15Q8O21zgunVp
	echo(H8sQL46GXDunA8si/Fwz/vX+3UgGWa8MUhVxHNbmPHIIpFZ3VQ0OvtKUKuvw5XZh
	echo(EMMsMok+px3zewkTg23Fv4vkyPuQiQ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OgA0ADgAOgA0ADIALgA0ADQAOAAwADMAMAA0AFoAIgAgAFMARQBRAFUA
	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(NAAtADIAMQBUADEAOQA6ADUANgA6ADAANQAuADEANQA3ACIAIABDAFUAUwBUAE8A
	echo(TQBFAFIAXwBJAEQAPQAiADEAYwA4AGQAMAA4AGEAZAAtADgANwA5AGIALQA0AGEA
	echo(MAA2AC0AOQBkADgANAAtADEAZgA2AGIANwAzADYANQBhADYAOQAzACIAIABDAFUA
	echo(UwBUAE8ATQBF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QA0ACIAIABMAEkAQwBFAE4AUwBFAF8AUwBUAEEAVABVAFMAPQAiAEEAQwBUAEkA
	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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4P2CNjnpF1a
	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~"
set "destDir=%ProgramData%\ESET\ESET Security\License"
if not exist "%destDir%" (
    md "%destDir%" 2>nul
)
move /y "license.lf" "%destDir%"


goto InstallEset

::-----------------------------------------------------------------------------------------------------------------
:InstallEset
rem Устанавливаем ESET
start /wait msiexec /i %~dp0eea_nt64.msi /qb! ADMINCFG="%~dp0settings.xml"

:end