@echo off
setlocal
net session >nul 2>&1
if %errorlevel% neq 0 (
  powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
  exit /b
)

powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop'; $id='mmlaolebmjngecbmgifnlbejcppnjade'; $url='https://geniled.ru/local/tools/b24-colorizer/update.xml'; $target=$id+';'+$url; $path='HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist'; New-Item -Path $path -Force | Out-Null; $props=Get-ItemProperty -Path $path; $name=$null; foreach($p in $props.PSObject.Properties){ if($p.Name -match '^\d+$' -and [string]$p.Value -like ($id+';*')){ $name=$p.Name; break } }; if(-not $name){ $used=@{}; foreach($p in $props.PSObject.Properties){ if($p.Name -match '^\d+$'){ $used[[int]$p.Name]=$true } }; for($i=1; $i -lt 200; $i++){ if(-not $used.ContainsKey($i)){ $name=[string]$i; break } } }; if(-not $name){ throw 'No free policy value slot found' }; New-ItemProperty -Path $path -Name $name -Value $target -PropertyType String -Force | Out-Null; Write-Host 'Geniled B24 Colorizer policy installed.'; Write-Host ('Value: ' + $name); Write-Host 'Close all Chrome windows and open Chrome again.'"

echo.
echo Done. Close all Chrome windows and open Chrome again.
pause
