Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing Add-Type -AssemblyName Microsoft.VisualBasic Add-Type @" using System; using System.Runtime.InteropServices; public class Win32 { [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("kernel32.dll")] public static extern IntPtr GetConsoleWindow(); } "@ # ========================== # CONSOLE VERSTECKEN (WICHTIG) # ========================== $consolePtr = [Win32]::GetConsoleWindow() if ($consolePtr -ne [IntPtr]::Zero) { [Win32]::ShowWindow($consolePtr, 0) # 0 = komplett verstecken } [System.Windows.Forms.Application]::EnableVisualStyles() # ========================== # SOURCE URL (WICHTIG für Restart) # ========================== $Global:SourceUrl = "https://winscript.dokware.de" # ========================== # ADMIN CHECK # ========================== $IsAdmin = ([Security.Principal.WindowsPrincipal] ` [Security.Principal.WindowsIdentity]::GetCurrent() ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) function Restart-AsAdmin { if (-not $Global:SourceUrl) { [System.Windows.Forms.MessageBox]::Show( "Keine URL gesetzt.", "Fehler", "OK", "Error" ) return } Start-Process powershell.exe -Verb RunAs -ArgumentList @( "-NoProfile", "-ExecutionPolicy Bypass", "-Command `"irm '$Global:SourceUrl' | iex`"" ) # WICHTIG: Exit NICHT direkt im Event Thread Start-Job { Start-Sleep 1; [Environment]::Exit(0) } | Out-Null } # ========================== # Farben # ========================== $PrimaryColor = [System.Drawing.Color]::FromArgb(0,102,204) $HoverColor = [System.Drawing.Color]::FromArgb(0,82,164) $WhiteColor = [System.Drawing.Color]::White $BorderColor = [System.Drawing.Color]::Gainsboro # ========================== # FORM # ========================== $form = New-Object System.Windows.Forms.Form $form.Text = "dokware.de Service Center" $form.Size = New-Object System.Drawing.Size(650,550) $form.StartPosition = "CenterScreen" $form.BackColor = $WhiteColor $form.FormBorderStyle = "FixedSingle" $form.MaximizeBox = $false $form.Font = New-Object System.Drawing.Font("Segoe UI",10) # ========================== # HEADER # ========================== $header = New-Object System.Windows.Forms.Panel $header.Dock = "Top" $header.Height = 110 $header.BackColor = $WhiteColor $form.Controls.Add($header) # Linie $line = New-Object System.Windows.Forms.Panel $line.Dock = "Bottom" $line.Height = 1 $line.BackColor = $BorderColor $header.Controls.Add($line) # LOGO $picLogo = New-Object System.Windows.Forms.PictureBox $picLogo.Size = New-Object System.Drawing.Size(300,80) $picLogo.Location = New-Object System.Drawing.Point(20,15) $picLogo.SizeMode = "Zoom" try { $wc = New-Object Net.WebClient $picLogo.Image = [System.Drawing.Image]::FromStream( $wc.OpenRead("https://dokware.de/logo2012-400px.png") ) } catch {} $header.Controls.Add($picLogo) # ========================== # ADMIN STATUS # ========================== $adminLabel = New-Object System.Windows.Forms.Label $adminLabel.AutoSize = $true $adminLabel.Location = New-Object System.Drawing.Point(340,20) $adminLabel.Font = New-Object System.Drawing.Font("Segoe UI",10,[System.Drawing.FontStyle]::Bold) if ($IsAdmin) { $adminLabel.Text = "Status: Administrator" $adminLabel.ForeColor = [System.Drawing.Color]::Green } else { $adminLabel.Text = "Status: Kein Administrator" $adminLabel.ForeColor = [System.Drawing.Color]::Red } $header.Controls.Add($adminLabel) # ========================== # ADMIN BUTTON # ========================== $adminBtn = New-Object System.Windows.Forms.Button $adminBtn.Text = "Als Administrator neu starten" $adminBtn.Size = New-Object System.Drawing.Size(250,30) $adminBtn.Location = New-Object System.Drawing.Point(340,50) $adminBtn.BackColor = $PrimaryColor $adminBtn.ForeColor = $WhiteColor $adminBtn.FlatStyle = "Flat" $adminBtn.FlatAppearance.BorderSize = 0 $adminBtn.Add_Click({ Restart-AsAdmin }) if ($IsAdmin) { $adminBtn.Enabled = $false $adminBtn.BackColor = [System.Drawing.Color]::LightGray } $header.Controls.Add($adminBtn) # ========================== # BUTTON FACTORY # ========================== function New-ModernButton { param($Text, $Y) $btn = New-Object System.Windows.Forms.Button $btn.Text = $Text $btn.Size = New-Object System.Drawing.Size(500,45) $btn.Location = New-Object System.Drawing.Point(70,$Y) $btn.BackColor = $PrimaryColor $btn.ForeColor = $WhiteColor $btn.FlatStyle = "Flat" $btn.FlatAppearance.BorderSize = 0 $btn.Cursor = "Hand" $btn.Font = New-Object System.Drawing.Font("Segoe UI",11) $btn.Add_MouseEnter({ $this.BackColor = $HoverColor }) $btn.Add_MouseLeave({ $this.BackColor = $PrimaryColor }) return $btn } # ========================== # FUNCTIONS # ========================== $btn1 = New-ModernButton "01 Systemsteuerung" 140 $btn1.Add_Click({ Start-Process "control.exe" }) $form.Controls.Add($btn1) $btn2 = New-ModernButton "02 Programme deinstallieren" 195 $btn2.Add_Click({ Start-Process "appwiz.cpl" }) $form.Controls.Add($btn2) $btn3 = New-ModernButton "03 Druckerverwaltung" 250 $btn3.Add_Click({ Start-Process "printmanagement.msc" }) $form.Controls.Add($btn3) $MailCfg = "C:\Program Files\Microsoft Office\root\Office16\mlcfg32.cpl" $btn4 = New-ModernButton "04 Mail-Konten Konfiguration" 305 if (-not (Test-Path $MailCfg)) { $btn4.Enabled = $false $btn4.BackColor = [System.Drawing.Color]::LightGray $btn4.ForeColor = [System.Drawing.Color]::DarkGray } $btn4.Add_Click({ Start-Process $MailCfg }) $form.Controls.Add($btn4) $btn5 = New-ModernButton "05 Herunterfahren" 360 $btn5.Add_Click({ $Minuten = [Microsoft.VisualBasic.Interaction]::InputBox( "Nach wie vielen Minuten?", "Herunterfahren", "30" ) if ($Minuten -match '^\d+$') { Start-Process shutdown.exe "-s -t $([int]$Minuten*60)" } }) $form.Controls.Add($btn5) # ========================== # FOOTER # ========================== $footer = New-Object System.Windows.Forms.StatusStrip $status = New-Object System.Windows.Forms.ToolStripStatusLabel $status.Spring = $true $status.TextAlign = "MiddleRight" $status.Text = "Ein Service von dokware.de" $footer.Items.Add($status) $form.Controls.Add($footer) # ========================== # START # ========================== [void]$form.ShowDialog()