38 lines
1.8 KiB
PowerShell
38 lines
1.8 KiB
PowerShell
# Скрипт установки расширения через PowerShell (альтернатива .reg файлу)
|
||
# Запускать с правами администратора:
|
||
# Right Click -> "Запустить от имени администратора"
|
||
# или: Start-Process powershell -Verb RunAs -ArgumentList "-File install-client.ps1"
|
||
|
||
param(
|
||
[string]$ExtensionId = "EXTENSION_ID",
|
||
[string]$UpdateUrl = "https://YOUR_DOMAIN/caps-enhancer/update.xml"
|
||
)
|
||
|
||
$registryPath = "HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist"
|
||
$value = "$ExtensionId;$UpdateUrl"
|
||
|
||
# Создаём ключ если не существует
|
||
if (-not (Test-Path $registryPath)) {
|
||
New-Item -Path $registryPath -Force | Out-Null
|
||
Write-Host "[OK] Создан ключ реестра: $registryPath"
|
||
}
|
||
|
||
# Ищем свободный номер (1, 2, 3, ...)
|
||
$index = 1
|
||
while (Get-ItemProperty -Path $registryPath -Name "$index" -ErrorAction SilentlyContinue) {
|
||
# Проверяем, вдруг расширение уже добавлено
|
||
$existing = (Get-ItemProperty -Path $registryPath -Name "$index")."$index"
|
||
if ($existing -like "$ExtensionId;*") {
|
||
Write-Host "[INFO] Расширение уже установлено (запись $index)."
|
||
Write-Host " Значение: $existing"
|
||
exit 0
|
||
}
|
||
$index++
|
||
}
|
||
|
||
Set-ItemProperty -Path $registryPath -Name "$index" -Value $value -Type String
|
||
Write-Host "[OK] Расширение добавлено в реестр (запись $index):"
|
||
Write-Host " $value"
|
||
Write-Host ""
|
||
Write-Host "Chrome автоматически установит расширение при следующем запуске."
|
||
Write-Host "Если Chrome уже открыт — перезапустите его."
|