62 lines
3.2 KiB
PowerShell
62 lines
3.2 KiB
PowerShell
## Fragt nach Admin Rechten.
|
|
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
|
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
|
|
Start-Process powershell -Verb runAs -ArgumentList $arguments
|
|
Break
|
|
}
|
|
Set-Location $HOME/.winconfig
|
|
|
|
# Log starten
|
|
if ((Test-Path $HOME/.winconfig/logs) -eq $False){
|
|
New-Item $HOME/.winconfig/logs/
|
|
}
|
|
Start-Transcript -Path $HOME/.winconfig/logs/run.log | out-null
|
|
|
|
# Menü laden
|
|
$inputXML = Get-Content "menu\menu.xaml"
|
|
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
|
[xml]$XAML = $inputXML
|
|
$reader = (New-Object System.Xml.XmlNodeReader $xaml)
|
|
try { $Form = [Windows.Markup.XamlReader]::Load( $reader ) }
|
|
catch [System.Management.Automation.MethodInvocationException] {
|
|
Write-Warning "We ran into a problem with the XAML code. Check the syntax for this control..."
|
|
write-host $error[0].Exception.Message -ForegroundColor Red
|
|
If ($error[0].Exception.Message -like "*button*") {
|
|
write-warning "Ensure your <button in the `$inputXML does NOT have a Click=ButtonClick property. PS can't handle this`n`n`n`n"
|
|
}
|
|
}
|
|
catch {
|
|
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
|
|
}
|
|
|
|
$xaml.SelectNodes("//*[@Name]") | ForEach-Object { Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name) }
|
|
|
|
# Einbinden der debloat.ps1
|
|
#. .\debloat.ps1
|
|
|
|
# Konfig für die prompts
|
|
#$choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
|
|
#$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
|
|
#$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
|
|
|
|
|
|
$WPFremove.Add_Click({
|
|
# Crap deinstallieren
|
|
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command Start-Transcript ~/.winconfig/logs/winget-remove.log -Append | out-null; . ./config.ps1 ; RemoveSoftware | Out-Host" -WindowStyle Normal
|
|
})
|
|
$WPFinstall.Add_Click({
|
|
# Software installieren
|
|
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command Start-Transcript ~/.winconfig/logs/winget-install.log -Append | out-null; . ./config.ps1 ; InstallSoftware | Out-Host" -WindowStyle Normal
|
|
})
|
|
$WPFinstallopt.Add_Click({
|
|
# Optionale Software installieren
|
|
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command Start-Transcript ~/.winconfig/logs/winget-installopt.log -Append | out-null; . ./config.ps1 ; InstallSoftwareOpt | Out-Host" -WindowStyle Normal
|
|
})
|
|
$WPFconfigure.Add_Click({
|
|
# Windows debloating
|
|
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command Start-Transcript ~/.winconfig/logs/winget-debloat.log -Append | out-null; . ./config.ps1 ; DebloatWindows | Out-Host" -WindowStyle Normal
|
|
})
|
|
|
|
$Form.ShowDialog() | out-null
|
|
Stop-Transcript
|