From 5ca482aa466b443ab528d5b5fc1e9dfc32ccd6a7 Mon Sep 17 00:00:00 2001 From: Mattia Tadini Date: Tue, 11 Nov 2025 15:05:20 +0000 Subject: [PATCH] Update install-AdHoc-Backup-GUI.ps1 --- install-AdHoc-Backup-GUI.ps1 | 53 ++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/install-AdHoc-Backup-GUI.ps1 b/install-AdHoc-Backup-GUI.ps1 index 4dee86d..ac7368d 100644 --- a/install-AdHoc-Backup-GUI.ps1 +++ b/install-AdHoc-Backup-GUI.ps1 @@ -1,16 +1,14 @@ #Requires -Version 5.1 <# -Installer AdHoc Backup (GUI) - v1.3.1 -- Tab "Configurazione (backup.conf)" con UI dinamica -- Eseguibili: C:\polo\scripts\bin\RClone e C:\polo\scripts\bin\7Zip -- Config: C:\polo\scripts\bin\conf\backup.conf e C:\polo\scripts\bin\conf\rclone.conf -- Dopo l'estrazione elimina gli ZIP -- Estrattore ZIP robusto (entry-per-entry, overwrite=true) -- Fix Point/Size (helper New-Point/New-Size) -- Schedulazione via schtasks; -Config punta a bin\conf\backup.conf -- Chiude console aperte (rclone, ecc.) alla chiusura -- FIX: avvio "Configura rclone" senza cmd.exe (Start-Process diretto su rclone.exe) per evitare l'errore "La sintassi del nome del file..." -- Minor: corretto flag Quiet in attività pianificata (-Quiet) +Installer AdHoc Backup (GUI) - v1.3.4 +- Tab "Configurazione (backup.conf)" con UI dinamica (checkbox per booleani, textbox per altri valori) +- Struttura: C:\polo\scripts\bin\RClone\ C:\polo\scripts\bin\7Zip\ C:\polo\scripts\bin\conf\ +- Config: C:\polo\scripts\bin\conf\backup.conf e C:\polo\scripts\bin\conf\rclone.conf +- "Installa": scarica/installa Rclone e **solo 7zr.exe** (nessun alias 7z.exe) nelle cartelle bin\ +- Dopo estrazione elimina ZIP di Rclone +- Avvio "Configura rclone" con Start-Process diretto (no cmd.exe) +- Schedulazione giornaliera/settimanale via schtasks; AdHoc-Backup.ps1 avviato con -Config +- Chiusura di tutte le console aperte dall’installer alla chiusura della finestra #> Add-Type -AssemblyName System.Windows.Forms @@ -20,12 +18,8 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem $ErrorActionPreference = 'Stop' # ------------------------------ HELPERS GRAFICI ------------------------------- -function New-Point([object]$x,[object]$y) { - try { return New-Object System.Drawing.Point ([int]$x), ([int]$y) } catch { return [System.Drawing.Point]::new([int]$x, [int]$y) } -} -function New-Size([object]$w,[object]$h) { - try { return New-Object System.Drawing.Size ([int]$w), ([int]$h) } catch { return [System.Drawing.Size]::new([int]$w, [int]$h) } -} +function New-Point([object]$x,[object]$y) { try { return New-Object System.Drawing.Point ([int]$x), ([int]$y) } catch { return [System.Drawing.Point]::new([int]$x, [int]$y) } } +function New-Size([object]$w,[object]$h) { try { return New-Object System.Drawing.Size ([int]$w), ([int]$h) } catch { return [System.Drawing.Size]::new([int]$w, [int]$h) } } function Set-Loc($ctrl,[object]$x,[object]$y){ $ctrl.Location = New-Point $x $y } function Set-Sz($ctrl,[object]$w,[object]$h){ $ctrl.Size = New-Size $w $h } @@ -123,10 +117,8 @@ function Ensure-RcloneExe { $zip = Join-Path $RcloneDir 'rclone-current-windows-amd64.zip' if (Start-Download -Url 'https://downloads.rclone.org/rclone-current-windows-amd64.zip' -Dest $zip) { Expand-Zip -ZipPath $zip -DestDir $RcloneDir - # Trova il vero rclone.exe estratto (cartella rclone-*-windows-amd64\) $found = Get-ChildItem -LiteralPath $RcloneDir -Recurse -Filter 'rclone.exe' | Select-Object -First 1 if ($found) { Copy-Item -LiteralPath $found.FullName -Destination $exe -Force } - # Pulisci cartella estratta e ZIP Get-ChildItem -LiteralPath $RcloneDir -Directory | Where-Object { $_.Name -like 'rclone-*' } | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -LiteralPath $zip -Force -ErrorAction SilentlyContinue } @@ -134,6 +126,21 @@ function Ensure-RcloneExe { return $exe } +# === SOLO 7zr.exe ============================================================= +function Ensure-SevenZipExe { + param([Parameter(Mandatory)][string]$SevenZipDir) + $exe = Join-Path $SevenZipDir '7zr.exe' + if (-not (Test-Path -LiteralPath $exe)) { + $url7zr = 'https://www.7-zip.org/a/7zr.exe' + if (Start-Download -Url $url7zr -Dest $exe) { + Write-Log "Installato 7-Zip minimal: $exe" + } else { + Write-Log "Impossibile installare 7-Zip (7zr.exe)." 'ERR' + } + } + return $exe +} + # ------------------------------ CONF PARSER ----------------------------------- $global:ChildPids = New-Object System.Collections.ArrayList function Track-Child($p){ if ($p -and $p.Id) { [void]$global:ChildPids.Add($p.Id) } } @@ -289,7 +296,7 @@ $btnSaveConf.Add_Click({ } catch { Write-Log "Errore salvataggio backup.conf: $($_.Exception.Message)" 'ERR' } }) -# FIX: avvio rclone.exe diretto (niente cmd.exe) per evitare errori di quoting +# Avvio rclone config in console dedicata $btnRcloneConfig.Add_Click({ try { $layout = Ensure-ToolsLayout -Root $txtInstall.Text @@ -318,6 +325,12 @@ $btnInstall.Add_Click({ $root = $txtInstall.Text; Ensure-Dir $root $layout = Ensure-ToolsLayout -Root $root + # Scarica/installa Rclone e SOLO 7zr.exe + $rcloneExe = Ensure-RcloneExe -RcloneDir $layout.RClone + if (-not (Test-Path -LiteralPath $rcloneExe)) { Write-Log "ATTENZIONE: rclone.exe non installato." 'WARN' } + $sevenExe = Ensure-SevenZipExe -SevenZipDir $layout.SevenZip + if (-not (Test-Path -LiteralPath $sevenExe)) { Write-Log "ATTENZIONE: 7-Zip (7zr.exe) non installato." 'WARN' } + # Script principale $scriptPath = Join-Path $root 'AdHoc-Backup.ps1' if (-not (Start-Download -Url $txtScriptUrl.Text -Dest $scriptPath)) { throw "Impossibile scaricare lo script principale." }