Files
Inventaire-gestion/Scripts/Update_Version/Restauration.ps1
2026-04-27 18:33:58 +02:00

42 lines
1.2 KiB
PowerShell

$source = "\\mj91.fr\PyCharm\Ratio_Inventaires\Excel\prod"
$dest = "C:\Users\$env:USERNAME\Domo91"
$nomFichier = "Ratio_Restauration.xlsm"
$nomVersion = "Ratio_Restauration_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 Restauration")
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