$source = "\\mj91.fr\PyCharm\Ratio_Inventaires\Excel\prod" $dest = "C:\Users\$env:USERNAME\Domo91" $nomFichier = "Ratio_Cuisine.xlsm" $nomVersion = "Ratio_Cuisine_VERSION.txt" $sourceXlsm = Join-Path $source $nomFichier $sourceVersion = Join-Path $source $nomVersion $destXlsm = Join-Path $dest $nomFichier $destVersion = Join-Path $dest $nomVersion if (!(Test-Path $dest)) { New-Item -ItemType Directory -Path $dest -Force | Out-Null } if (!(Test-Path $sourceVersion)) { Add-Type -AssemblyName PresentationFramework [System.Windows.MessageBox]::Show("Le dossier de mise à jour sur le NAS est inaccessible.", "Mise à jour Ratio Cuisine") exit } $versionServeur = (Get-Content $sourceVersion -ErrorAction Stop).Trim() if (Test-Path $destVersion) { $versionLocale = (Get-Content $destVersion -ErrorAction SilentlyContinue).Trim() } else { $versionLocale = "" } if ($versionServeur -ne $versionLocale) { $excel = Get-Process EXCEL -ErrorAction SilentlyContinue if ($excel) { $excel | Stop-Process -Force Start-Sleep -Seconds 2 } Copy-Item -Path $sourceXlsm -Destination $destXlsm -Force Copy-Item -Path $sourceVersion -Destination $destVersion -Force } Start-Process $destXlsm