# Install.ps1 # Script to install the folder backup context menu integration # Check for admin rights $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { Write-Host "Bu komut dosyası yönetici ayrıcalıkları gerektirir. Lütfen Yönetici olarak çalıştırın." -ForegroundColor Red exit 1 } # Get the current script directory $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition # Path to the backup script $BackupScriptPath = Join-Path $ScriptDir "BackupFolder.ps1" # Check if backup script exists if (-not (Test-Path $BackupScriptPath)) { Write-Host "Hata: BackupFolder.ps1 dosyası $ScriptDir dizininde bulunamadı" -ForegroundColor Red exit 1 } Write-Host "Klasör Yedekleme Sağ Tık Menüsü Entegrasyonu Kuruluyor..." -ForegroundColor Green # Define registry paths $FolderContextMenuPath = "Registry::HKEY_CLASSES_ROOT\Directory\shell\BackupFolder" $BackgroundContextMenuPath = "Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\BackupFolder" try { # Create folder context menu entry New-Item -Path $FolderContextMenuPath -Force | Out-Null New-ItemProperty -Path $FolderContextMenuPath -Name "(Default)" -Value "Yedekle ve Sıkıştır" -PropertyType String -Force | Out-Null New-ItemProperty -Path $FolderContextMenuPath -Name "Icon" -Value "powershell.exe" -PropertyType String -Force | Out-Null # Create command subkey for folder context menu $FolderCommandPath = "$FolderContextMenuPath\command" New-Item -Path $FolderCommandPath -Force | Out-Null $CommandValue = "powershell.exe -ExecutionPolicy Bypass -File `"$BackupScriptPath`" -FolderPath `"%V`"" New-ItemProperty -Path $FolderCommandPath -Name "(Default)" -Value $CommandValue -PropertyType String -Force | Out-Null # Create background context menu entry New-Item -Path $BackgroundContextMenuPath -Force | Out-Null New-ItemProperty -Path $BackgroundContextMenuPath -Name "(Default)" -Value "Yedekle ve Sıkıştır" -PropertyType String -Force | Out-Null New-ItemProperty -Path $BackgroundContextMenuPath -Name "Icon" -Value "powershell.exe" -PropertyType String -Force | Out-Null # Create command subkey for background context menu $BackgroundCommandPath = "$BackgroundContextMenuPath\command" New-Item -Path $BackgroundCommandPath -Force | Out-Null $BackgroundCommandValue = "powershell.exe -ExecutionPolicy Bypass -File `"$BackupScriptPath`" -FolderPath `"%V`"" New-ItemProperty -Path $BackgroundCommandPath -Name "(Default)" -Value $BackgroundCommandValue -PropertyType String -Force | Out-Null Write-Host "Kurulum başarıyla tamamlandı!" -ForegroundColor Green Write-Host "Artık klasörler üzerinde veya boş alanda sağ tıklayarak yedekleme ve sıkıştırma yapabilirsiniz." -ForegroundColor Yellow } catch { Write-Host "Kurulum sırasında hata oluştu: $($_.Exception.Message)" -ForegroundColor Red }