@echo off
chcp 65001 >nul
title Mise a jour AirPlay v14.6.6
echo ========================================================
echo       MISE A JOUR AIRPLAY EN COURS (v14.6.6)...
echo ========================================================
echo.
echo 1. Fermeture des anciennes instances d'AirPlay...
taskkill /F /IM AirPlay.exe >nul 2>&1
timeout /t 2 /nobreak >nul

set "TARGET=%LOCALAPPDATA%\Programs\AirPlay"
set "SOURCE=\\5.180.34.122\nas\airplay_data\update\app_latest"

echo 2. Installation des nouveaux fichiers vers :
echo    %TARGET%
echo.
if not exist "%TARGET%" mkdir "%TARGET%"

robocopy "%SOURCE%" "%TARGET%" /E /R:3 /W:1 /NP /NFL /NDL >nul

echo 3. Mise a jour du raccourci Bureau...
powershell -NoProfile -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut([System.IO.Path]::Combine([Environment]::GetFolderPath('Desktop'), 'AirPlay.lnk')); $s.TargetPath = [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Programs\AirPlay\AirPlay.exe'); $s.IconLocation = [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Programs\AirPlay\AirPlay.exe,0'); $s.Save()"

echo.
echo ========================================================
echo       MISE A JOUR REUSSIE ! LANCEMENT D'AIRPLAY...
echo ========================================================
start "" "%TARGET%\AirPlay.exe"
exit
