mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
code format using powershell VS code extension (#28)
This commit is contained in:
parent
b670968731
commit
4d2364072e
274
winutil.ps1
274
winutil.ps1
@ -8,13 +8,13 @@
|
|||||||
# $inputXML = Get-Content "MainWindow.xaml" #uncomment for development
|
# $inputXML = Get-Content "MainWindow.xaml" #uncomment for development
|
||||||
$inputXML = (new-object Net.WebClient).DownloadString("https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/MainWindow.xaml") #uncomment for Production
|
$inputXML = (new-object Net.WebClient).DownloadString("https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/MainWindow.xaml") #uncomment for Production
|
||||||
|
|
||||||
$inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
|
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
||||||
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
||||||
[xml]$XAML = $inputXML
|
[xml]$XAML = $inputXML
|
||||||
#Read XAML
|
#Read XAML
|
||||||
|
|
||||||
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
|
$reader = (New-Object System.Xml.XmlNodeReader $xaml)
|
||||||
try{$Form=[Windows.Markup.XamlReader]::Load( $reader )}
|
try { $Form = [Windows.Markup.XamlReader]::Load( $reader ) }
|
||||||
catch [System.Management.Automation.MethodInvocationException] {
|
catch [System.Management.Automation.MethodInvocationException] {
|
||||||
Write-Warning "We ran into a problem with the XAML code. Check the syntax for this control..."
|
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
|
write-host $error[0].Exception.Message -ForegroundColor Red
|
||||||
@ -22,20 +22,21 @@ catch [System.Management.Automation.MethodInvocationException] {
|
|||||||
write-warning "Ensure your <button in the `$inputXML does NOT have a Click=ButtonClick property. PS can't handle this`n`n`n`n"
|
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{# If it broke some other way <img draggable="false" role="img" class="emoji" alt="😀" src="https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/svg/1f600.svg">
|
catch {
|
||||||
|
# If it broke some other way <img draggable="false" role="img" class="emoji" alt="😀" src="https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/svg/1f600.svg">
|
||||||
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
|
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
|
||||||
}
|
}
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Store Form Objects In PowerShell
|
# Store Form Objects In PowerShell
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
|
||||||
$xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name)}
|
$xaml.SelectNodes("//*[@Name]") | % { Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name) }
|
||||||
|
|
||||||
Function Get-FormVariables{
|
Function Get-FormVariables {
|
||||||
If ($global:ReadmeDisplay -ne $true){Write-host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow;$global:ReadmeDisplay=$true}
|
If ($global:ReadmeDisplay -ne $true) { Write-host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow; $global:ReadmeDisplay = $true }
|
||||||
write-host "Found the following interactable elements from our form" -ForegroundColor Cyan
|
write-host "Found the following interactable elements from our form" -ForegroundColor Cyan
|
||||||
get-variable WPF*
|
get-variable WPF*
|
||||||
}
|
}
|
||||||
|
|
||||||
Get-FormVariables
|
Get-FormVariables
|
||||||
@ -49,7 +50,7 @@ $WPFTab1BT.Add_Click({
|
|||||||
$WPFTabNav.Items[1].IsSelected = $false
|
$WPFTabNav.Items[1].IsSelected = $false
|
||||||
$WPFTabNav.Items[2].IsSelected = $false
|
$WPFTabNav.Items[2].IsSelected = $false
|
||||||
$WPFTabNav.Items[3].IsSelected = $false
|
$WPFTabNav.Items[3].IsSelected = $false
|
||||||
})
|
})
|
||||||
$WPFTab2BT.Add_Click({
|
$WPFTab2BT.Add_Click({
|
||||||
$WPFTabNav.Items[0].IsSelected = $false
|
$WPFTabNav.Items[0].IsSelected = $false
|
||||||
$WPFTabNav.Items[1].IsSelected = $true
|
$WPFTabNav.Items[1].IsSelected = $true
|
||||||
@ -380,10 +381,13 @@ $WPFinstall.Add_Click({
|
|||||||
|
|
||||||
# Check if winget is installed
|
# Check if winget is installed
|
||||||
Write-Host "Checking if Winget is Installed..."
|
Write-Host "Checking if Winget is Installed..."
|
||||||
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){ #Checks if winget executable exists and if the Windows Version is 1809 or higher
|
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe) {
|
||||||
|
#Checks if winget executable exists and if the Windows Version is 1809 or higher
|
||||||
Write-Host "Winget Already Installed"
|
Write-Host "Winget Already Installed"
|
||||||
}else{
|
}
|
||||||
if(((((Get-ComputerInfo).OSName.IndexOf("LTSC")) -ne -1) -or ((Get-ComputerInfo).OSName.IndexOf("Server") -ne -1)) -and (((Get-ComputerInfo).WindowsVersion) -ge "1809")){#Checks if Windows edition is LTSC/Server 2019+
|
else {
|
||||||
|
if (((((Get-ComputerInfo).OSName.IndexOf("LTSC")) -ne -1) -or ((Get-ComputerInfo).OSName.IndexOf("Server") -ne -1)) -and (((Get-ComputerInfo).WindowsVersion) -ge "1809")) {
|
||||||
|
#Checks if Windows edition is LTSC/Server 2019+
|
||||||
#Manually Installing Winget
|
#Manually Installing Winget
|
||||||
Write-Host "Running Alternative Installer for LTSC/Server Editions"
|
Write-Host "Running Alternative Installer for LTSC/Server Editions"
|
||||||
|
|
||||||
@ -409,9 +413,12 @@ $WPFinstall.Add_Click({
|
|||||||
Remove-Item -Path ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force
|
Remove-Item -Path ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -Force
|
||||||
Remove-Item -Path ".\b0a0692da1034339b76dce1c298a1e42_License1.xml" -Force
|
Remove-Item -Path ".\b0a0692da1034339b76dce1c298a1e42_License1.xml" -Force
|
||||||
Write-Host "Removed Files that are no longer needed"
|
Write-Host "Removed Files that are no longer needed"
|
||||||
}elseif(((Get-ComputerInfo).WindowsVersion) -lt "1809"){ #Checks if Windows Version is too old for winget
|
}
|
||||||
|
elseif (((Get-ComputerInfo).WindowsVersion) -lt "1809") {
|
||||||
|
#Checks if Windows Version is too old for winget
|
||||||
Write-Host "Winget is not supported on this version of Windows (Pre-1809)"
|
Write-Host "Winget is not supported on this version of Windows (Pre-1809)"
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
#Installing Winget from the Microsoft Store
|
#Installing Winget from the Microsoft Store
|
||||||
Write-Host "Winget not found, installing it now."
|
Write-Host "Winget not found, installing it now."
|
||||||
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
|
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
|
||||||
@ -425,8 +432,7 @@ $WPFinstall.Add_Click({
|
|||||||
$wingetinstall.ToArray()
|
$wingetinstall.ToArray()
|
||||||
# Define Output variable
|
# Define Output variable
|
||||||
$wingetResult = New-Object System.Collections.Generic.List[System.Object]
|
$wingetResult = New-Object System.Collections.Generic.List[System.Object]
|
||||||
foreach ( $node in $wingetinstall )
|
foreach ( $node in $wingetinstall ) {
|
||||||
{
|
|
||||||
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command winget install -e --accept-source-agreements --accept-package-agreements --silent $node | Out-Host" -Wait -WindowStyle Maximized
|
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command winget install -e --accept-source-agreements --accept-package-agreements --silent $node | Out-Host" -Wait -WindowStyle Maximized
|
||||||
$wingetResult.Add("$node`n")
|
$wingetResult.Add("$node`n")
|
||||||
}
|
}
|
||||||
@ -439,9 +445,9 @@ $WPFinstall.Add_Click({
|
|||||||
$Messageboxbody = ($wingetResult)
|
$Messageboxbody = ($wingetResult)
|
||||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||||
|
|
||||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$WPFInstallUpgrade.Add_Click({
|
$WPFInstallUpgrade.Add_Click({
|
||||||
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command winget upgrade --all | Out-Host" -Wait -WindowStyle Maximized
|
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command winget upgrade --all | Out-Host" -Wait -WindowStyle Maximized
|
||||||
@ -451,8 +457,8 @@ $WPFInstallUpgrade.Add_Click({
|
|||||||
$Messageboxbody = ("Done")
|
$Messageboxbody = ("Done")
|
||||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||||
|
|
||||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||||
})
|
})
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Tab 2 - Tweak Buttons
|
# Tab 2 - Tweak Buttons
|
||||||
@ -475,7 +481,7 @@ $WPFdesktop.Add_Click({
|
|||||||
$WPFMiscTweaksNum.IsChecked = $true
|
$WPFMiscTweaksNum.IsChecked = $true
|
||||||
$WPFMiscTweaksLapPower.IsChecked = $false
|
$WPFMiscTweaksLapPower.IsChecked = $false
|
||||||
$WPFMiscTweaksLapNum.IsChecked = $false
|
$WPFMiscTweaksLapNum.IsChecked = $false
|
||||||
})
|
})
|
||||||
|
|
||||||
$WPFlaptop.Add_Click({
|
$WPFlaptop.Add_Click({
|
||||||
|
|
||||||
@ -495,7 +501,7 @@ $WPFlaptop.Add_Click({
|
|||||||
$WPFMiscTweaksLapNum.IsChecked = $true
|
$WPFMiscTweaksLapNum.IsChecked = $true
|
||||||
$WPFMiscTweaksPower.IsChecked = $false
|
$WPFMiscTweaksPower.IsChecked = $false
|
||||||
$WPFMiscTweaksNum.IsChecked = $false
|
$WPFMiscTweaksNum.IsChecked = $false
|
||||||
})
|
})
|
||||||
|
|
||||||
$WPFminimal.Add_Click({
|
$WPFminimal.Add_Click({
|
||||||
|
|
||||||
@ -515,7 +521,7 @@ $WPFminimal.Add_Click({
|
|||||||
$WPFMiscTweaksNum.IsChecked = $false
|
$WPFMiscTweaksNum.IsChecked = $false
|
||||||
$WPFMiscTweaksLapPower.IsChecked = $false
|
$WPFMiscTweaksLapPower.IsChecked = $false
|
||||||
$WPFMiscTweaksLapNum.IsChecked = $false
|
$WPFMiscTweaksLapNum.IsChecked = $false
|
||||||
})
|
})
|
||||||
|
|
||||||
$WPFtweaksbutton.Add_Click({
|
$WPFtweaksbutton.Add_Click({
|
||||||
|
|
||||||
@ -757,7 +763,8 @@ $WPFtweaksbutton.Add_Click({
|
|||||||
Stop-Process $taskmgr
|
Stop-Process $taskmgr
|
||||||
$preferences.Preferences[28] = 0
|
$preferences.Preferences[28] = 0
|
||||||
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences
|
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences
|
||||||
} else {Write-Host "Task Manager patch not run in builds 22557+ due to bug"}
|
}
|
||||||
|
else { Write-Host "Task Manager patch not run in builds 22557+ due to bug" }
|
||||||
|
|
||||||
Write-Host "Showing file operations details..."
|
Write-Host "Showing file operations details..."
|
||||||
If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager")) {
|
If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager")) {
|
||||||
@ -876,7 +883,7 @@ $WPFtweaksbutton.Add_Click({
|
|||||||
Write-Host "Adjusting visual effects for performance..."
|
Write-Host "Adjusting visual effects for performance..."
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 0
|
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 0
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 200
|
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 200
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](144,18,3,128,16,0,0,0))
|
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](144, 18, 3, 128, 16, 0, 0, 0))
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 0
|
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 0
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay" -Type DWord -Value 0
|
Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay" -Type DWord -Value 0
|
||||||
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Type DWord -Value 0
|
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Type DWord -Value 0
|
||||||
@ -983,7 +990,7 @@ $WPFtweaksbutton.Add_Click({
|
|||||||
Write-Host "Removing Bloatware"
|
Write-Host "Removing Bloatware"
|
||||||
|
|
||||||
foreach ($Bloat in $Bloatware) {
|
foreach ($Bloat in $Bloatware) {
|
||||||
Get-AppxPackage -Name $Bloat| Remove-AppxPackage
|
Get-AppxPackage -Name $Bloat | Remove-AppxPackage
|
||||||
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online
|
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online
|
||||||
Write-Host "Trying to remove $Bloat."
|
Write-Host "Trying to remove $Bloat."
|
||||||
}
|
}
|
||||||
@ -996,8 +1003,8 @@ $WPFtweaksbutton.Add_Click({
|
|||||||
$Messageboxbody = ("Done")
|
$Messageboxbody = ("Done")
|
||||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||||
|
|
||||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||||
})
|
})
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Undo All
|
# Undo All
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
@ -1114,7 +1121,7 @@ $WPFundoall.Add_Click({
|
|||||||
Write-Output "Adjusting visual effects for appearance..."
|
Write-Output "Adjusting visual effects for appearance..."
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 1
|
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 1
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 400
|
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 400
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](158,30,7,128,18,0,0,0))
|
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](158, 30, 7, 128, 18, 0, 0, 0))
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 1
|
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 1
|
||||||
Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay" -Type DWord -Value 1
|
Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay" -Type DWord -Value 1
|
||||||
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Type DWord -Value 1
|
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Type DWord -Value 1
|
||||||
@ -1135,8 +1142,8 @@ $WPFundoall.Add_Click({
|
|||||||
$Messageboxbody = ("Done")
|
$Messageboxbody = ("Done")
|
||||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||||
|
|
||||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||||
})
|
})
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Tab 3 - Config Buttons
|
# Tab 3 - Config Buttons
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
@ -1185,60 +1192,60 @@ $WPFFeatureInstall.Add_Click({
|
|||||||
$Messageboxbody = ("Done")
|
$Messageboxbody = ("Done")
|
||||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||||
|
|
||||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||||
})
|
})
|
||||||
|
|
||||||
$WPFPanelDISM.Add_Click({
|
$WPFPanelDISM.Add_Click({
|
||||||
Start-Process PowerShell -ArgumentList 'Write-Host "Chkdsk" -ForegroundColor Green; Chkdsk;
|
Start-Process PowerShell -ArgumentList 'Write-Host "Chkdsk" -ForegroundColor Green; Chkdsk;
|
||||||
Write-Host "SFC - 1st scan" -ForegroundColor Green; sfc /scannow;
|
Write-Host "SFC - 1st scan" -ForegroundColor Green; sfc /scannow;
|
||||||
Write-Host "DISM" -ForegroundColor Green; DISM /Online /Cleanup-Image /Restorehealth;
|
Write-Host "DISM" -ForegroundColor Green; DISM /Online /Cleanup-Image /Restorehealth;
|
||||||
Write-Host "SFC - 2nd scan" -ForegroundColor Green; sfc /scannow;
|
Write-Host "SFC - 2nd scan" -ForegroundColor Green; sfc /scannow;
|
||||||
Read-Host "Press Enter"' -verb runas
|
Read-Host "Press Enter"' -verb runas
|
||||||
})
|
})
|
||||||
|
|
||||||
$WPFPanelcontrol.Add_Click({
|
$WPFPanelcontrol.Add_Click({
|
||||||
cmd /c control
|
cmd /c control
|
||||||
})
|
})
|
||||||
$WPFPanelnetwork.Add_Click({
|
$WPFPanelnetwork.Add_Click({
|
||||||
cmd /c ncpa.cpl
|
cmd /c ncpa.cpl
|
||||||
})
|
})
|
||||||
$WPFPanelpower.Add_Click({
|
$WPFPanelpower.Add_Click({
|
||||||
cmd /c powercfg.cpl
|
cmd /c powercfg.cpl
|
||||||
})
|
})
|
||||||
$WPFPanelsound.Add_Click({
|
$WPFPanelsound.Add_Click({
|
||||||
cmd /c mmsys.cpl
|
cmd /c mmsys.cpl
|
||||||
})
|
})
|
||||||
$WPFPanelsystem.Add_Click({
|
$WPFPanelsystem.Add_Click({
|
||||||
cmd /c sysdm.cpl
|
cmd /c sysdm.cpl
|
||||||
})
|
})
|
||||||
$WPFPaneluser.Add_Click({
|
$WPFPaneluser.Add_Click({
|
||||||
cmd /c "control userpasswords2"
|
cmd /c "control userpasswords2"
|
||||||
})
|
})
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Tab 4 - Updates Buttons
|
# Tab 4 - Updates Buttons
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
|
||||||
$WPFUpdatesdefault.Add_Click({
|
$WPFUpdatesdefault.Add_Click({
|
||||||
# Source: https://github.com/rgl/windows-vagrant/blob/master/disable-windows-updates.ps1 reversed!
|
# Source: https://github.com/rgl/windows-vagrant/blob/master/disable-windows-updates.ps1 reversed!
|
||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
$ProgressPreference = 'SilentlyContinue'
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
trap {
|
trap {
|
||||||
Write-Host
|
Write-Host
|
||||||
Write-Host "ERROR: $_"
|
Write-Host "ERROR: $_"
|
||||||
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
|
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$', 'ERROR: $1')
|
||||||
Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1')
|
Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$', 'ERROR EXCEPTION: $1')
|
||||||
Write-Host
|
Write-Host
|
||||||
Write-Host 'Sleeping for 60m to give you time to look around the virtual machine before self-destruction...'
|
Write-Host 'Sleeping for 60m to give you time to look around the virtual machine before self-destruction...'
|
||||||
Start-Sleep -Seconds (60*60)
|
Start-Sleep -Seconds (60 * 60)
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# disable automatic updates.
|
# disable automatic updates.
|
||||||
# XXX this does not seem to work anymore.
|
# XXX this does not seem to work anymore.
|
||||||
# see How to configure automatic updates by using Group Policy or registry settings
|
# see How to configure automatic updates by using Group Policy or registry settings
|
||||||
# at https://support.microsoft.com/en-us/help/328010
|
# at https://support.microsoft.com/en-us/help/328010
|
||||||
function New-Directory($path) {
|
function New-Directory($path) {
|
||||||
$p, $components = $path -split '[\\/]'
|
$p, $components = $path -split '[\\/]'
|
||||||
$components | ForEach-Object {
|
$components | ForEach-Object {
|
||||||
$p = "$p\$_"
|
$p = "$p\$_"
|
||||||
@ -1247,25 +1254,25 @@ function New-Directory($path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$null
|
$null
|
||||||
}
|
}
|
||||||
$auPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
|
$auPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
|
||||||
New-Directory $auPath
|
New-Directory $auPath
|
||||||
# set NoAutoUpdate.
|
# set NoAutoUpdate.
|
||||||
# 0: Automatic Updates is enabled (default).
|
# 0: Automatic Updates is enabled (default).
|
||||||
# 1: Automatic Updates is disabled.
|
# 1: Automatic Updates is disabled.
|
||||||
New-ItemProperty `
|
New-ItemProperty `
|
||||||
-Path $auPath `
|
-Path $auPath `
|
||||||
-Name NoAutoUpdate `
|
-Name NoAutoUpdate `
|
||||||
-Value 0 `
|
-Value 0 `
|
||||||
-PropertyType DWORD `
|
-PropertyType DWORD `
|
||||||
-Force `
|
-Force `
|
||||||
| Out-Null
|
| Out-Null
|
||||||
# set AUOptions.
|
# set AUOptions.
|
||||||
# 1: Keep my computer up to date has been disabled in Automatic Updates.
|
# 1: Keep my computer up to date has been disabled in Automatic Updates.
|
||||||
# 2: Notify of download and installation.
|
# 2: Notify of download and installation.
|
||||||
# 3: Automatically download and notify of installation.
|
# 3: Automatically download and notify of installation.
|
||||||
# 4: Automatically download and scheduled installation.
|
# 4: Automatically download and scheduled installation.
|
||||||
New-ItemProperty `
|
New-ItemProperty `
|
||||||
-Path $auPath `
|
-Path $auPath `
|
||||||
-Name AUOptions `
|
-Name AUOptions `
|
||||||
-Value 3 `
|
-Value 3 `
|
||||||
@ -1273,13 +1280,13 @@ New-ItemProperty `
|
|||||||
-Force `
|
-Force `
|
||||||
| Out-Null
|
| Out-Null
|
||||||
|
|
||||||
# disable Windows Update Delivery Optimization.
|
# disable Windows Update Delivery Optimization.
|
||||||
# NB this applies to Windows 10.
|
# NB this applies to Windows 10.
|
||||||
# 0: Disabled
|
# 0: Disabled
|
||||||
# 1: PCs on my local network
|
# 1: PCs on my local network
|
||||||
# 3: PCs on my local network, and PCs on the Internet
|
# 3: PCs on my local network, and PCs on the Internet
|
||||||
$deliveryOptimizationPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config'
|
$deliveryOptimizationPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config'
|
||||||
If (Test-Path $deliveryOptimizationPath) {
|
If (Test-Path $deliveryOptimizationPath) {
|
||||||
New-ItemProperty `
|
New-ItemProperty `
|
||||||
-Path $deliveryOptimizationPath `
|
-Path $deliveryOptimizationPath `
|
||||||
-Name DODownloadMode `
|
-Name DODownloadMode `
|
||||||
@ -1287,20 +1294,20 @@ If (Test-Path $deliveryOptimizationPath) {
|
|||||||
-PropertyType DWORD `
|
-PropertyType DWORD `
|
||||||
-Force `
|
-Force `
|
||||||
| Out-Null
|
| Out-Null
|
||||||
}
|
}
|
||||||
# Service tweaks for Windows Update
|
# Service tweaks for Windows Update
|
||||||
|
|
||||||
$services = @(
|
$services = @(
|
||||||
"BITS"
|
"BITS"
|
||||||
"wuauserv"
|
"wuauserv"
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach ($service in $services) {
|
foreach ($service in $services) {
|
||||||
# -ErrorAction SilentlyContinue is so it doesn't write an error to stdout if a service doesn't exist
|
# -ErrorAction SilentlyContinue is so it doesn't write an error to stdout if a service doesn't exist
|
||||||
|
|
||||||
Write-Host "Setting $service StartupType to Automatic"
|
Write-Host "Setting $service StartupType to Automatic"
|
||||||
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Automatic
|
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Automatic
|
||||||
}
|
}
|
||||||
Write-Host "Enabling driver offering through Windows Update..."
|
Write-Host "Enabling driver offering through Windows Update..."
|
||||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -ErrorAction SilentlyContinue
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -ErrorAction SilentlyContinue
|
||||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -ErrorAction SilentlyContinue
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -ErrorAction SilentlyContinue
|
||||||
@ -1314,7 +1321,7 @@ foreach ($service in $services) {
|
|||||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "BranchReadinessLevel" -ErrorAction SilentlyContinue
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "BranchReadinessLevel" -ErrorAction SilentlyContinue
|
||||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferFeatureUpdatesPeriodInDays" -ErrorAction SilentlyContinue
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferFeatureUpdatesPeriodInDays" -ErrorAction SilentlyContinue
|
||||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferQualityUpdatesPeriodInDays " -ErrorAction SilentlyContinue
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferQualityUpdatesPeriodInDays " -ErrorAction SilentlyContinue
|
||||||
})
|
})
|
||||||
$WPFFixesUpdate.Add_Click({
|
$WPFFixesUpdate.Add_Click({
|
||||||
### Reset Windows Update Script - reregister dlls, services, and remove registry entires.
|
### Reset Windows Update Script - reregister dlls, services, and remove registry entires.
|
||||||
Write-Host "1. Stopping Windows Update Services..."
|
Write-Host "1. Stopping Windows Update Services..."
|
||||||
@ -1394,7 +1401,8 @@ $WPFFixesUpdate.Add_Click({
|
|||||||
Write-Host "10) Attempting to install the Windows Update Agent..."
|
Write-Host "10) Attempting to install the Windows Update Agent..."
|
||||||
If ($arch -eq 64) {
|
If ($arch -eq 64) {
|
||||||
wusa Windows8-RT-KB2937636-x64 /quiet
|
wusa Windows8-RT-KB2937636-x64 /quiet
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
wusa Windows8-RT-KB2937636-x86 /quiet
|
wusa Windows8-RT-KB2937636-x86 /quiet
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1414,29 +1422,29 @@ $WPFFixesUpdate.Add_Click({
|
|||||||
$Messageboxbody = ("Stock settings loaded.`n Please reboot your computer")
|
$Messageboxbody = ("Stock settings loaded.`n Please reboot your computer")
|
||||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||||
|
|
||||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||||
})
|
})
|
||||||
$WPFUpdatesdisable.Add_Click({
|
$WPFUpdatesdisable.Add_Click({
|
||||||
# Source: https://github.com/rgl/windows-vagrant/blob/master/disable-windows-updates.ps1
|
# Source: https://github.com/rgl/windows-vagrant/blob/master/disable-windows-updates.ps1
|
||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
$ProgressPreference = 'SilentlyContinue'
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
trap {
|
trap {
|
||||||
Write-Host
|
Write-Host
|
||||||
Write-Host "ERROR: $_"
|
Write-Host "ERROR: $_"
|
||||||
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
|
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$', 'ERROR: $1')
|
||||||
Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1')
|
Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$', 'ERROR EXCEPTION: $1')
|
||||||
Write-Host
|
Write-Host
|
||||||
Write-Host 'Sleeping for 60m to give you time to look around the virtual machine before self-destruction...'
|
Write-Host 'Sleeping for 60m to give you time to look around the virtual machine before self-destruction...'
|
||||||
Start-Sleep -Seconds (60*60)
|
Start-Sleep -Seconds (60 * 60)
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# disable automatic updates.
|
# disable automatic updates.
|
||||||
# XXX this does not seem to work anymore.
|
# XXX this does not seem to work anymore.
|
||||||
# see How to configure automatic updates by using Group Policy or registry settings
|
# see How to configure automatic updates by using Group Policy or registry settings
|
||||||
# at https://support.microsoft.com/en-us/help/328010
|
# at https://support.microsoft.com/en-us/help/328010
|
||||||
function New-Directory($path) {
|
function New-Directory($path) {
|
||||||
$p, $components = $path -split '[\\/]'
|
$p, $components = $path -split '[\\/]'
|
||||||
$components | ForEach-Object {
|
$components | ForEach-Object {
|
||||||
$p = "$p\$_"
|
$p = "$p\$_"
|
||||||
@ -1445,25 +1453,25 @@ function New-Directory($path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$null
|
$null
|
||||||
}
|
}
|
||||||
$auPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
|
$auPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
|
||||||
New-Directory $auPath
|
New-Directory $auPath
|
||||||
# set NoAutoUpdate.
|
# set NoAutoUpdate.
|
||||||
# 0: Automatic Updates is enabled (default).
|
# 0: Automatic Updates is enabled (default).
|
||||||
# 1: Automatic Updates is disabled.
|
# 1: Automatic Updates is disabled.
|
||||||
New-ItemProperty `
|
New-ItemProperty `
|
||||||
-Path $auPath `
|
-Path $auPath `
|
||||||
-Name NoAutoUpdate `
|
-Name NoAutoUpdate `
|
||||||
-Value 1 `
|
-Value 1 `
|
||||||
-PropertyType DWORD `
|
-PropertyType DWORD `
|
||||||
-Force `
|
-Force `
|
||||||
| Out-Null
|
| Out-Null
|
||||||
# set AUOptions.
|
# set AUOptions.
|
||||||
# 1: Keep my computer up to date has been disabled in Automatic Updates.
|
# 1: Keep my computer up to date has been disabled in Automatic Updates.
|
||||||
# 2: Notify of download and installation.
|
# 2: Notify of download and installation.
|
||||||
# 3: Automatically download and notify of installation.
|
# 3: Automatically download and notify of installation.
|
||||||
# 4: Automatically download and scheduled installation.
|
# 4: Automatically download and scheduled installation.
|
||||||
New-ItemProperty `
|
New-ItemProperty `
|
||||||
-Path $auPath `
|
-Path $auPath `
|
||||||
-Name AUOptions `
|
-Name AUOptions `
|
||||||
-Value 1 `
|
-Value 1 `
|
||||||
@ -1471,13 +1479,13 @@ New-ItemProperty `
|
|||||||
-Force `
|
-Force `
|
||||||
| Out-Null
|
| Out-Null
|
||||||
|
|
||||||
# disable Windows Update Delivery Optimization.
|
# disable Windows Update Delivery Optimization.
|
||||||
# NB this applies to Windows 10.
|
# NB this applies to Windows 10.
|
||||||
# 0: Disabled
|
# 0: Disabled
|
||||||
# 1: PCs on my local network
|
# 1: PCs on my local network
|
||||||
# 3: PCs on my local network, and PCs on the Internet
|
# 3: PCs on my local network, and PCs on the Internet
|
||||||
$deliveryOptimizationPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config'
|
$deliveryOptimizationPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config'
|
||||||
If (Test-Path $deliveryOptimizationPath) {
|
If (Test-Path $deliveryOptimizationPath) {
|
||||||
New-ItemProperty `
|
New-ItemProperty `
|
||||||
-Path $deliveryOptimizationPath `
|
-Path $deliveryOptimizationPath `
|
||||||
-Name DODownloadMode `
|
-Name DODownloadMode `
|
||||||
@ -1485,22 +1493,22 @@ If (Test-Path $deliveryOptimizationPath) {
|
|||||||
-PropertyType DWORD `
|
-PropertyType DWORD `
|
||||||
-Force `
|
-Force `
|
||||||
| Out-Null
|
| Out-Null
|
||||||
}
|
}
|
||||||
# Service tweaks for Windows Update
|
# Service tweaks for Windows Update
|
||||||
|
|
||||||
$services = @(
|
$services = @(
|
||||||
"BITS"
|
"BITS"
|
||||||
"wuauserv"
|
"wuauserv"
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach ($service in $services) {
|
foreach ($service in $services) {
|
||||||
# -ErrorAction SilentlyContinue is so it doesn't write an error to stdout if a service doesn't exist
|
# -ErrorAction SilentlyContinue is so it doesn't write an error to stdout if a service doesn't exist
|
||||||
|
|
||||||
Write-Host "Setting $service StartupType to Disabled"
|
Write-Host "Setting $service StartupType to Disabled"
|
||||||
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Disabled
|
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
$WPFUpdatessecurity.Add_Click({
|
$WPFUpdatessecurity.Add_Click({
|
||||||
Write-Host "Disabling driver offering through Windows Update..."
|
Write-Host "Disabling driver offering through Windows Update..."
|
||||||
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata")) {
|
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata")) {
|
||||||
@ -1533,8 +1541,8 @@ $WPFUpdatessecurity.Add_Click({
|
|||||||
$Messageboxbody = ("Recommended Update settings loaded")
|
$Messageboxbody = ("Recommended Update settings loaded")
|
||||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||||
|
|
||||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||||
})
|
})
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Shows the form
|
# Shows the form
|
||||||
|
Loading…
Reference in New Issue
Block a user