
Kod: Tümünü seç
# -------------------------------------------------
# Gelişmiş Kısayol & Sembolik Link Oluşturucu
# TRWE_2012 için - Güvenli sürüm
# -------------------------------------------------
Add-Type -AssemblyName System.Windows.Forms
# Kullanıcıdan hedef seçim
$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Title = "Uygulama (exe) ya da klasör seçin"
$dialog.Filter = "Tüm dosyalar ve klasörler (*.*)|*.*"
$dialog.Multiselect = $false
if (-not $dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
Write-Host "Seçim yapılmadı, betik sonlandırılıyor."
exit
}
$targetPath = $dialog.FileName
Write-Host "`nSeçilen yol:`n$targetPath"
# Masaüstü yolu
$desktop = [Environment]::GetFolderPath('Desktop')
Write-Host "`nNot: Bu betik orijinal dosya/klasörü değiştirmez, sadece masaüstünde kısayol/symlink oluşturur.`n"
# Kullanıcıya seçim sor
Write-Host "Hangi işlem(ler) yapılsın?"
Write-Host "1 - Masaüstünde kısayol (.lnk)"
Write-Host "2 - Masaüstünde sembolik link (symlink)"
Write-Host "3 - Her ikisi"
$secim = Read-Host "Seçiminizi yapın (1/2/3)"
# Kullanıcıdan masaüstünde kullanılacak isim
$customName = Read-Host "Masaüstünde oluşturulacak nesnenin ismini girin"
# -------------------------------------------------
# 1. Kısayol (.lnk) oluşturma
# -------------------------------------------------
if ($secim -eq "1" -or $secim -eq "3") {
$shortcutPath = Join-Path $desktop ($customName + ".lnk")
if (Test-Path $shortcutPath) {
$cevap = Read-Host "Masaüstünde aynı isimli kısayol zaten var. Üzerine yazılsın mı? (E/H)"
if ($cevap -ne "E" -and $cevap -ne "e") {
Write-Host "Kısayol oluşturma iptal edildi."
$shortcutPath = $null
} else {
Remove-Item $shortcutPath -Force
}
}
if ($shortcutPath) {
$wshShell = New-Object -ComObject WScript.Shell
$shortcut = $wshShell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $targetPath
$shortcut.WorkingDirectory = Split-Path $targetPath
$shortcut.WindowStyle = 1
$shortcut.IconLocation = $targetPath
$shortcut.Save()
Write-Host "`nKısayol oluşturuldu:`n$shortcutPath"
}
}
# -------------------------------------------------
# 2. Sembolik link oluşturma (Yönetici kontrolü ile)
# -------------------------------------------------
if ($secim -eq "2" -or $secim -eq "3") {
$isAdmin = ([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent() `
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Warning "Yönetici yetkisi yok. Sembolik link oluşturulamayacak."
}
else {
$linkPath = Join-Path $desktop $customName
if (Test-Path $linkPath) {
$cevap = Read-Host "Masaüstünde aynı isimli symlink zaten var. Üzerine yazılsın mı? (E/H)"
if ($cevap -ne "E" -and $cevap -ne "e") {
Write-Host "Symlink oluşturma iptal edildi."
$linkPath = $null
} else {
Remove-Item $linkPath -Force
}
}
if ($linkPath) {
try {
if (Test-Path $targetPath -PathType Container) {
# Klasör symlink
cmd /c mklink /D "`"$linkPath`"" "`"$targetPath`""
} else {
# Dosya symlink
cmd /c mklink "`"$linkPath`"" "`"$targetPath`""
}
Write-Host "`nSembolik link oluşturuldu:`n$linkPath"
}
catch {
Write-Warning "Sembolik link oluşturulamadı."
}
}
}
}

