
Kod: Tümünü seç
# Widgets Kill Switch - Tam Rollback + Log Uyumlu Sürüm (TRWE_2012)
# Windows11 24H2/25H2 uyumlu, Home/Pro sürümleri destekli
# --- Yönetici Kontrolü ---
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "Bu betik YÖNETİCİ olarak çalıştırılmalıdır!" -ForegroundColor Red
exit 1
}
# --- Dosya ve Klasör Yolları ---
$AppDataPath = "C:\ProgramData\WidgetsKillSwitch"
if (-not (Test-Path $AppDataPath)) { New-Item -Path $AppDataPath -ItemType Directory -Force | Out-Null }
$LogFile = Join-Path $AppDataPath "widgets_kill_switch.log"
$BackupFile = Join-Path $AppDataPath "widgets_backup.json"
$RegPath = "HKLM:\SOFTWARE\Policies\Microsoft\Dsh"
# --- Yardımcı Fonksiyonlar ---
function Write-Log { param([string]$Message,[string]$Level="INFO") $ts=(Get-Date).ToString("yyyy-MM-dd HH:mm:ss"); $line="[$ts] [$Level] $Message"; try { Add-Content -Path $LogFile -Value $line -Encoding UTF8 } catch {}; Write-Host $line }
function Pause-Press { Write-Host "Devam etmek için bir tuşa basın..." -ForegroundColor Cyan; $null=$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") }
# --- Yedekleme ve Rollback ---
function Backup-State {
Write-Log "Yedekleme başlatıldı"
$state=@{}
if (Test-Path $RegPath) {
$props=Get-ItemProperty -Path $RegPath -ErrorAction SilentlyContinue | Select-Object -Property *
$regHash=@{}
foreach ($p in $props.PSObject.Properties.Name) { if ($p -notin @('PSPath','PSParentPath','PSChildName','PSDrive','PSProvider')) { $regHash[$p]=$props.$p } }
$state.Registry=$regHash
} else { $state.Registry=$null }
$state.FirewallRules=@()
$state.LastBackup=(Get-Date).ToString("o")
try { $state | ConvertTo-Json -Depth 7 | Set-Content -Path $BackupFile -Encoding UTF8 } catch { Write-Log "Yedek dosyası yazılamadı" "WARN" }
Write-Log "Yedekleme tamamlandı -> $BackupFile"
}
function Get-SavedFirewallRules { if (Test-Path $BackupFile) { try { $b=Get-Content $BackupFile -Raw | ConvertFrom-Json -ErrorAction Stop; return $b.FirewallRules } catch { return @() } } else { return @() } }
function Stop-WidgetProcesses { $procNames=@('Widgets','WebExperienceHost','SearchApp'); foreach($name in $procNames){ try{ $procs=Get-Process -Name $name -ErrorAction SilentlyContinue; if($procs){ foreach($p in $procs){ try{ Stop-Process -Id $p.Id -Force -ErrorAction Stop; Write-Log "Süreç durduruldu: $($p.Name) (Id:$($p.Id))" } catch { Write-Log "Süreç durdurulamadı: $($p.Name) - $_" "WARN" } } } } catch{} } }
function Disable-Widgets {
Write-Log "Disable-Widgets başlatılıyor"
try {
Backup-State
if (-not (Test-Path $RegPath)) { New-Item -Path $RegPath -Force | Out-Null }
Set-ItemProperty -Path $RegPath -Name AllowNewsAndInterests -Value 0 -Type DWord -ErrorAction Stop
Set-ItemProperty -Path $RegPath -Name EnableFloatingWidgets -Value 0 -Type DWord -ErrorAction Stop
Write-Log "Registry policy anahtarları ayarlandı"
Start-Process -FilePath gpupdate.exe -ArgumentList '/force' -NoNewWindow -Wait | Out-Null
$pkg=Get-AppxPackage -Name 'MicrosoftWindows.Client.WebExperience' -ErrorAction SilentlyContinue | Select-Object -First 1
if($pkg){
$exePath=Join-Path $pkg.InstallLocation 'Dashboard\Widgets.exe'
if(Test-Path $exePath){
$ruleName='WKS_Block_Widgets.exe'
try { netsh advfirewall firewall delete rule name="$ruleName" program="$exePath" 2>$null | Out-Null } catch {}
netsh advfirewall firewall add rule name="$ruleName" dir=out action=block program="$exePath" enable=yes profile=any
Write-Log "Firewall kuralı eklendi: $ruleName -> $exePath"
} else { Write-Log "Widgets.exe bulunamadı" "WARN" }
} else { Write-Log "WebExperience paketi bulunamadı" "WARN" }
Stop-WidgetProcesses
Write-Log "Disable-Widgets tamamlandı"
} catch { Write-Log "Disable-Widgets hata: $_" "ERROR" }
}
function Enable-Widgets {
Write-Log "Enable-Widgets (geri alma) başlatılıyor"
try {
if(Test-Path $RegPath){ Remove-ItemProperty -Path $RegPath -Name AllowNewsAndInterests -ErrorAction SilentlyContinue; Remove-ItemProperty -Path $RegPath -Name EnableFloatingWidgets -ErrorAction SilentlyContinue; Write-Log "Registry policy anahtarları kaldırıldı" }
$rules=Get-SavedFirewallRules
foreach($r in $rules){ try{ netsh advfirewall firewall delete rule name="$($r.Name)" program="$($r.Program)" 2>$null | Out-Null; Write-Log "Firewall kuralı silindi: $($r.Name)" } catch { Write-Log "Kural silinirken hata: $_" "WARN" } }
if(Test-Path $BackupFile){ Remove-Item -Path $BackupFile -ErrorAction SilentlyContinue }
Stop-WidgetProcesses
Write-Log "Enable-Widgets tamamlandı"
} catch { Write-Log "Enable-Widgets hata: $_" "ERROR" }
}
# --- Menü ---
function Show-Menu { Clear-Host; Write-Host "==============================================================="; Write-Host " Widgets Mekanizması Engelleme Yöneticisine Hoşgeldiniz "; Write-Host "==============================================================="; Write-Host "0. Mevcut Durumu Sorgula (Widgets Açık/Kapalı Mı?)"; Write-Host "1. Hemen Widgets Mekanizmasını Kalıcı Engelle"; Write-Host "2. Kalıcı Engellenen Widgets Mekanizmasını Varsayılan Hale Getir"; Write-Host "3. Betikten Çık"; Write-Host "===============================================================" }
function Get-WidgetsStatus {
$allow = (Get-ItemProperty -Path $RegPath -Name AllowNewsAndInterests -ErrorAction SilentlyContinue).AllowNewsAndInterests
$float = (Get-ItemProperty -Path $RegPath -Name EnableFloatingWidgets -ErrorAction SilentlyContinue).EnableFloatingWidgets
if ($allow -eq 0 -and $float -eq 0) { Write-Host "Widgets Durumu: KAPALI (Politika ile devre dışı)." -ForegroundColor Green }
else { Write-Host "Widgets Durumu: AÇIK veya KISMI (Politika uygulanmamış)." -ForegroundColor Yellow }
Pause-Press
}
# --- Ana Döngü ---
while($true){
Show-Menu
$secim=Read-Host "Seçiminizi Yapınız"
switch($secim){
'0'{ Get-WidgetsStatus }
'1'{ Disable-Widgets; Pause-Press }
'2'{ Enable-Widgets; Pause-Press }
'3'{ Write-Log "Betik sonlandı kullanıcı tarafından"; Write-Host "Betikten çıkılıyor..."; exit 0 }
default { Write-Host "Geçersiz seçim!" -ForegroundColor Red; Pause-Press }
}
}
Write-Host "Betikten çıkıldı."
Karakter kodlamasını UTF-8'den ANSI'ye çevirin ki Türkçe karakter sorunu oluşmasın.
Artık Windows11-10 asla arka planda gizlice netinizi sömüremeyecek....
Güle güle kullanın....




