$ErrorActionPreference = 'Stop' $cfg = 'G:\WEB-SERVER\htdocs\AttendanceHub\ZKTecoSyncService-V2\publish\config\phase1.device.json' $stamp = Get-Date -Format 'yyyyMMdd_HHmmss' Copy-Item $cfg "$cfg.bak_uploadfix_$stamp" -Force $t = [System.IO.File]::ReadAllText($cfg) $pattern = '("upload"\s*:\s*\{\s*"enabled"\s*:\s*)false' $new = [regex]::Replace($t, $pattern, '${1}true', 1) if ($new -eq $t) { throw 'upload.enabled=false pattern not found - ABORTING, no change made' } [System.IO.File]::WriteAllText($cfg, $new, [System.Text.UTF8Encoding]$false) Write-Output '--- patched upload block ---' ([regex]::Match($new, '(?s)"upload"\s*:\s*\{.{0,120}')).Value Stop-Service -Name 'ZKTecoSyncService' -Force Start-Sleep -Seconds 3 Start-Service -Name 'ZKTecoSyncService' Start-Sleep -Seconds 6 Get-Service -Name 'ZKTecoSyncService' | Select-Object Name, Status | Format-Table -AutoSize