v1.4.0: Auto-update from network share
- Checks S:\DT\cameron\eDNC-Fix\version.ini every 5 minutes - Auto-downloads new files and restarts if newer version found - Added version.ini file - Deploy.bat now includes version.ini 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,9 +36,13 @@
|
||||
|
||||
.NOTES
|
||||
Author: GE Aerospace - Rutland
|
||||
Version: 1.3.0
|
||||
Version: 1.4.0
|
||||
Date: 2025-12-12
|
||||
|
||||
v1.4.0 - Auto-update:
|
||||
- Checks S:\DT\cameron\eDNC-Fix\version.ini every 5 minutes
|
||||
- Auto-downloads and restarts if newer version found
|
||||
|
||||
v1.3.0 - Fixed header UI:
|
||||
- GE Aerospace ASCII banner stays at top
|
||||
- Live status updates in header (Processing, Cleaned, Failed)
|
||||
@@ -74,9 +78,15 @@ param(
|
||||
)
|
||||
|
||||
# Script info
|
||||
$ScriptVersion = "1.3.0"
|
||||
$ScriptVersion = "1.4.0"
|
||||
$ScriptName = "eDNC Special Character Fix"
|
||||
|
||||
# Auto-update settings
|
||||
$UpdateSource = "S:\DT\cameron\eDNC-Fix"
|
||||
$LocalPath = "C:\eDNC-Fix"
|
||||
$UpdateCheckInterval = 300 # Check every 5 minutes (in seconds)
|
||||
$script:LastUpdateCheck = [DateTime]::MinValue
|
||||
|
||||
# Header display function
|
||||
function Show-Header {
|
||||
param([int]$Cleaned = 0, [int]$Failed = 0, [string]$Status = "Watching...")
|
||||
@@ -134,6 +144,67 @@ function Show-Header {
|
||||
return $headerLines.Count
|
||||
}
|
||||
|
||||
# Auto-update function
|
||||
function Check-ForUpdate {
|
||||
$versionFile = Join-Path $UpdateSource "version.ini"
|
||||
|
||||
# Skip if source not available
|
||||
if (-not (Test-Path $versionFile)) {
|
||||
return $false
|
||||
}
|
||||
|
||||
try {
|
||||
# Read version from INI file
|
||||
$content = Get-Content $versionFile -Raw
|
||||
if ($content -match 'Version=(\d+\.\d+\.\d+)') {
|
||||
$remoteVersion = [version]$matches[1]
|
||||
$localVersion = [version]$ScriptVersion
|
||||
|
||||
if ($remoteVersion -gt $localVersion) {
|
||||
return $remoteVersion.ToString()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
# Silently fail if can't read
|
||||
}
|
||||
|
||||
return $false
|
||||
}
|
||||
|
||||
function Invoke-Update {
|
||||
param([string]$NewVersion)
|
||||
|
||||
Write-Host ""
|
||||
Write-Host " [UPDATE] New version $NewVersion available!" -ForegroundColor Magenta
|
||||
Write-Host " [UPDATE] Downloading update..." -ForegroundColor Magenta
|
||||
|
||||
try {
|
||||
# Copy new files
|
||||
$files = @("eDNC-SpecialCharFix.ps1", "Run-eDNCFix.bat", "Install-ScheduledTask.ps1", "version.ini")
|
||||
foreach ($file in $files) {
|
||||
$src = Join-Path $UpdateSource $file
|
||||
$dst = Join-Path $LocalPath $file
|
||||
if (Test-Path $src) {
|
||||
Copy-Item -Path $src -Destination $dst -Force
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host " [UPDATE] Update complete! Restarting..." -ForegroundColor Magenta
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
# Restart the script
|
||||
$scriptPath = Join-Path $LocalPath "eDNC-SpecialCharFix.ps1"
|
||||
Start-Process powershell.exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`"" -WindowStyle Normal
|
||||
|
||||
# Exit current instance
|
||||
exit 0
|
||||
}
|
||||
catch {
|
||||
Write-Host " [UPDATE] Update failed: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
# Initialize console
|
||||
Clear-Host
|
||||
$script:HeaderHeight = Show-Header -Status "Initializing..."
|
||||
@@ -313,6 +384,16 @@ $null = Register-ObjectEvent -InputObject $watcher -EventName Changed -Action $a
|
||||
try {
|
||||
while ($true) {
|
||||
Start-Sleep -Seconds 1
|
||||
|
||||
# Periodic update check
|
||||
$now = Get-Date
|
||||
if (($now - $script:LastUpdateCheck).TotalSeconds -ge $UpdateCheckInterval) {
|
||||
$script:LastUpdateCheck = $now
|
||||
$newVersion = Check-ForUpdate
|
||||
if ($newVersion) {
|
||||
Invoke-Update -NewVersion $newVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
Reference in New Issue
Block a user