From baceb22c7e736d974f4c12a1a505b1de9a91a2c7 Mon Sep 17 00:00:00 2001 From: "manuel.maier" Date: Mon, 18 May 2026 14:28:30 +0200 Subject: [PATCH] Dateien nach "/" hochladen --- Start_proxmoxclient_go_gui.bat | 2 + proxmoxclient_go_gui.ps1 | 710 ++++++++++++++++++++++++--------- 2 files changed, 516 insertions(+), 196 deletions(-) create mode 100644 Start_proxmoxclient_go_gui.bat diff --git a/Start_proxmoxclient_go_gui.bat b/Start_proxmoxclient_go_gui.bat new file mode 100644 index 0000000..ad28d0d --- /dev/null +++ b/Start_proxmoxclient_go_gui.bat @@ -0,0 +1,2 @@ +@echo off +powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0proxmoxclient_go_gui.ps1" diff --git a/proxmoxclient_go_gui.ps1 b/proxmoxclient_go_gui.ps1 index 1123475..d337f0e 100644 --- a/proxmoxclient_go_gui.ps1 +++ b/proxmoxclient_go_gui.ps1 @@ -1,239 +1,557 @@ -# --- Automatic Admin Restart (Self-Elevation) --- -if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { - $arguments = "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" - Start-Process powershell.exe -ArgumentList $arguments -Verb RunAs +# --- 1. Thread & Admin Check (WPF REQUIRES STA-Mode!) --- +$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +$isSTA = ([System.Threading.Thread]::CurrentThread.GetApartmentState() -eq 'STA') + +if (-not $isAdmin -or -not $isSTA) { + $argList = "-STA -NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" + if (-not $isAdmin) { + Start-Process "powershell.exe" -ArgumentList $argList -Verb "RunAs" + } else { + Start-Process "powershell.exe" -ArgumentList $argList + } exit } -Add-Type -AssemblyName System.Windows.Forms -Add-Type -AssemblyName System.Drawing +Add-Type -AssemblyName PresentationFramework -# --- Styling & Colors --- -$color_bg = [System.Drawing.Color]::FromArgb(45, 52, 71) -$color_sidebar = [System.Drawing.Color]::FromArgb(35, 40, 55) -$color_text = [System.Drawing.Color]::White -$color_accent = [System.Drawing.Color]::FromArgb(0, 120, 215) -$color_save = [System.Drawing.Color]::FromArgb(40, 167, 69) -$color_delete = [System.Drawing.Color]::FromArgb(220, 53, 69) -$font_main = New-Object System.Drawing.Font("Segoe UI", 10) -$font_bold = New-Object System.Drawing.Font("Segoe UI", 10, [System.Drawing.FontStyle]::Bold) +Add-Type -Name Window -Namespace Console -MemberDefinition ' +[DllImport("Kernel32.dll")] +public static extern IntPtr GetConsoleWindow(); -# --- Files & Paths --- +[DllImport("user32.dll")] +public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow); +' + +$consolePtr = [Console.Window]::GetConsoleWindow() +[Console.Window]::ShowWindow($consolePtr, 0) + +# --- 2. Load WPF Assemblies & Setup UTF8 without BOM --- +Add-Type -AssemblyName PresentationFramework +Add-Type -AssemblyName PresentationCore +Add-Type -AssemblyName WindowsBase + + +$utf8NoBom = New-Object System.Text.UTF8Encoding($false) + +# --- 3. Configuration Paths --- $jobFile = "$PSScriptRoot\backup_jobs.json" -if (-not (Test-Path $jobFile)) { "{}" | Out-File $jobFile -Encoding utf8 } +$mailFile = "$PSScriptRoot\email_settings.json" +if (-not (Test-Path $jobFile)) { [System.IO.File]::WriteAllText($jobFile, "{}", $utf8NoBom) } +if (-not (Test-Path $mailFile)) { [System.IO.File]::WriteAllText($mailFile, "{}", $utf8NoBom) } -$mainForm = New-Object System.Windows.Forms.Form -$mainForm.Text = "proxmoxbackupclient_go-GUI" -$mainForm.Size = "950, 850" -$mainForm.StartPosition = "CenterScreen" -$mainForm.BackColor = $color_bg -$mainForm.ForeColor = $color_text +# --- 4. XAML UI Definition --- +$xaml = @' + + + + + + + + + + + + + + + + + +