Mise en place maj auto
This commit is contained in:
42
Excel/prod/Cuisine.ps1
Normal file
42
Excel/prod/Cuisine.ps1
Normal file
@@ -0,0 +1,42 @@
|
||||
$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
|
||||
Reference in New Issue
Block a user