Files
hfbackup/Install.ps1
2025-11-14 01:21:50 +03:00

57 lines
3.0 KiB
PowerShell

# 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
}