@echo off
setlocal EnableExtensions
chcp 65001 >nul

title Tamer SEO Analyzer - Masaustu Kisayolu Olustur
set "INSTALL_DIR=%LOCALAPPDATA%\Programs\Tamer SEO Analyzer"

if not exist "%INSTALL_DIR%\Tamer SEO Analyzer.bat" (
    echo HATA: Program kurulu gorunmuyor.
    echo Once Tamer_SEO_Analyzer_Setup.bat dosyasini calistirin.
    echo Beklenen klasor:
    echo %INSTALL_DIR%
    pause
    exit /b 1
)

set "SHORTCUT_PS=%TEMP%\tamer_seo_manual_shortcut.ps1"
(
  echo param^([string]$InstallDir^)
  echo $ErrorActionPreference = 'Stop'
  echo $Wsh = New-Object -ComObject WScript.Shell
  echo $Desktop = [Environment]::GetFolderPath^('Desktop'^)
  echo if ^([string]::IsNullOrWhiteSpace^($Desktop^)^) { $Desktop = Join-Path $env:USERPROFILE 'Desktop' }
  echo if ^(-not ^(Test-Path -LiteralPath $Desktop^)^) { New-Item -ItemType Directory -Path $Desktop -Force ^| Out-Null }
  echo $Target = Join-Path $InstallDir 'Tamer SEO Analyzer.bat'
  echo $Icon = Join-Path $InstallDir 'assets\tamer_seo_analyzer.ico'
  echo $Shortcut = Join-Path $Desktop 'Tamer SEO Analyzer.lnk'
  echo $S = $Wsh.CreateShortcut^($Shortcut^)
  echo $S.TargetPath = $Target
  echo $S.WorkingDirectory = $InstallDir
  echo if ^(Test-Path -LiteralPath $Icon^) { $S.IconLocation = $Icon }
  echo $S.Description = 'Tamer SEO Analyzer V1.4.2'
  echo $S.Save^(^)
  echo Write-Host "Kisayol olusturuldu: $Shortcut"
) > "%SHORTCUT_PS%"

powershell -NoProfile -ExecutionPolicy Bypass -File "%SHORTCUT_PS%" -InstallDir "%INSTALL_DIR%"
if %ERRORLEVEL% NEQ 0 (
    echo HATA: Kisayol olusturulamadi.
    echo Alternatif: Bu dosyaya sag tiklayip "Kisayol olustur" diyebilirsiniz:
    echo "%INSTALL_DIR%\Tamer SEO Analyzer.bat"
    pause
    exit /b 1
)

echo.
echo Masaustu kisayolu basariyla olusturuldu.
echo.
pause
endlocal
exit /b 0
