# ===================================================== # dokware.de Service Center # Version: 1.2 # # Start: # Win + R # powershell irm https://winscript.dokware.de | iex # # Funktionen: # 01 Systemsteuerung # 02 Programme deinstallieren # 03 Druckerverwaltung # 04 Mail-Konten Konfiguration # 05 Systeminformationen # 06 Herunterfahren # ===================================================== # ========================== # Benötigte .NET Bibliotheken laden # ========================== Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing Add-Type -AssemblyName Microsoft.VisualBasic # ========================== # Win32 Funktionen laden # (PowerShell-Fenster verstecken) # ========================== 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(); } "@ # ========================== # PowerShell-Konsole ausblenden # ========================== $consolePtr=[Win32]::GetConsoleWindow() if($consolePtr -ne [IntPtr]::Zero){ [Win32]::ShowWindow($consolePtr,0) } # Windows-Design aktivieren [System.Windows.Forms.Application]::EnableVisualStyles() # ========================== # Administratorrechte prüfen # ========================== $CurrentIdentity=[Security.Principal.WindowsIdentity]::GetCurrent() $CurrentPrincipal=New-Object Security.Principal.WindowsPrincipal($CurrentIdentity) $IsAdmin=$CurrentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) # ========================== # PC-Name und Windows-Version ermitteln # ========================== try{ $ComputerName=[System.Environment]::MachineName $os=Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" $build=[int]$os.CurrentBuildNumber $displayVersion=$os.DisplayVersion if(-not $displayVersion){ $displayVersion=$os.ReleaseId } if($build -ge 22000){ $edition=(Get-CimInstance Win32_OperatingSystem).Caption $edition=$edition ` -replace "Microsoft ","" ` -replace "Windows 10","Windows 11" $WindowsVersion="$edition $displayVersion" }else{ $WindowsVersion="$($os.ProductName) $displayVersion" } }catch{ $ComputerName=[System.Environment]::MachineName $WindowsVersion="Windows-Version unbekannt" } # ========================== # Script als Administrator neu starten # ========================== function Restart-AsAdmin { Start-Process powershell.exe ` -Verb RunAs ` -ArgumentList '-NoProfile -ExecutionPolicy Bypass -Command "irm https://winscript.dokware.de | iex"' $form.Close() } # ========================== # Farbdefinitionen # ========================== $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 # ========================== # Hauptfenster erstellen # ========================== $form=New-Object System.Windows.Forms.Form $form.Text="dokware.de Service Center" $form.Size=New-Object System.Drawing.Size(650,650) $form.StartPosition="CenterScreen" $form.BackColor=$WhiteColor $form.FormBorderStyle="FixedSingle" $form.MaximizeBox=$false $form.Font=New-Object System.Drawing.Font("Segoe UI",10) # ========================== # Header (Kopfbereich) # ========================== $header=New-Object System.Windows.Forms.Panel $header.Dock="Top" $header.Height=140 $header.BackColor=$WhiteColor $form.Controls.Add($header) # Trennlinie im Header $line=New-Object System.Windows.Forms.Panel $line.Dock="Bottom" $line.Height=1 $line.BackColor=$BorderColor $header.Controls.Add($line) # ========================== # dokware Logo laden # ========================== $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 System.Net.WebClient $stream=$wc.OpenRead("https://dokware.de/logo2012-400px.png") $picLogo.Image=[System.Drawing.Image]::FromStream($stream) }catch{} $header.Controls.Add($picLogo) # ========================== # Statusinformationen anzeigen # ========================== $adminLabel=New-Object System.Windows.Forms.Label $adminLabel.AutoSize=$true $adminLabel.Location=New-Object System.Drawing.Point(340,15) $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) # PC-Name anzeigen $pcLabel=New-Object System.Windows.Forms.Label $pcLabel.AutoSize=$true $pcLabel.Location=New-Object System.Drawing.Point(340,40) $pcLabel.Font=New-Object System.Drawing.Font("Segoe UI",9) $pcLabel.Text="PC: $ComputerName" $header.Controls.Add($pcLabel) # Windows-Version anzeigen $windowsLabel=New-Object System.Windows.Forms.Label $windowsLabel.AutoSize=$true $windowsLabel.Location=New-Object System.Drawing.Point(340,60) $windowsLabel.Font=New-Object System.Drawing.Font("Segoe UI",9) $windowsLabel.Text="Windows: $WindowsVersion" $header.Controls.Add($windowsLabel) # ========================== # Admin-Neustart 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,90) $adminBtn.BackColor=$PrimaryColor $adminBtn.ForeColor=$WhiteColor $adminBtn.FlatStyle="Flat" $adminBtn.FlatAppearance.BorderSize=0 $adminBtn.Cursor="Hand" if($IsAdmin){ $adminBtn.Enabled=$false $adminBtn.BackColor=[System.Drawing.Color]::LightGray }else{ $adminBtn.Add_Click({ Restart-AsAdmin }) } $header.Controls.Add($adminBtn) # ========================== # Vorlage für alle Menübuttons # ========================== function New-ModernButton{ param( [string]$Text, [int]$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) # Hovereffekt $btn.Add_MouseEnter({ $this.BackColor=$HoverColor }) $btn.Add_MouseLeave({ $this.BackColor=$PrimaryColor }) return $btn } # ========================== # Menüeinträge # ========================== # 01 Systemsteuerung $btn1=New-ModernButton "01 Systemsteuerung" 170 $btn1.Add_Click({ Start-Process control.exe }) $form.Controls.Add($btn1) # 02 Programme deinstallieren $btn2=New-ModernButton "02 Programme deinstallieren" 225 $btn2.Add_Click({ Start-Process appwiz.cpl }) $form.Controls.Add($btn2) # 03 Druckerverwaltung $btn3=New-ModernButton "03 Druckerverwaltung" 280 $btn3.Add_Click({ Start-Process printmanagement.msc }) $form.Controls.Add($btn3) # 04 Mail-Konten Konfiguration $MailCfg="C:\Program Files\Microsoft Office\root\Office16\mlcfg32.cpl" $btn4=New-ModernButton "04 Mail-Konten Konfiguration" 335 if(-not(Test-Path $MailCfg)){ $btn4.Enabled=$false $btn4.BackColor=[System.Drawing.Color]::LightGray $btn4.ForeColor=[System.Drawing.Color]::DarkGray }else{ $btn4.Add_Click({ Start-Process $MailCfg }) } $form.Controls.Add($btn4) # 05 Systeminformationen $btn5=New-ModernButton "05 Systeminformationen" 390 $btn5.Add_Click({ Start-Process msinfo32.exe }) $form.Controls.Add($btn5) # 06 Uhrzeit einstellen $btn6=New-ModernButton "06 Uhrzeit einstellen" 445 $btn6.Add_Click({ Start-Process timedate.cpl }) $form.Controls.Add($btn6) # 07 Herunterfahren $btn7=New-ModernButton "07 Herunterfahren" 500 $btn7.Add_Click({ $Minuten=[Microsoft.VisualBasic.Interaction]::InputBox( "Nach wie vielen Minuten soll der Computer heruntergefahren werden?", "Herunterfahren planen", "30" ) if($Minuten -match '^\d+$'){ $Sekunden=[int]$Minuten*60 Start-Process shutdown.exe -ArgumentList "-s -t $Sekunden" [System.Windows.Forms.MessageBox]::Show( "Der Computer wird in $Minuten Minute(n) heruntergefahren.", "Herunterfahren geplant" ) } }) $form.Controls.Add($btn7) # ========================== # Fußzeile (Footer) # ========================== $footer=New-Object System.Windows.Forms.StatusStrip $left=New-Object System.Windows.Forms.ToolStripStatusLabel $left.Text="Version 1.2" $right=New-Object System.Windows.Forms.ToolStripStatusLabel $right.Spring=$true $right.TextAlign="MiddleRight" $right.Text="Ein Service von dokware.de" $footer.Items.Add($left) $footer.Items.Add($right) $form.Controls.Add($footer) # ========================== # Anwendung starten # ========================== [void]$form.ShowDialog()