mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45: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 = (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')
|
||||
[xml]$XAML = $inputXML
|
||||
#Read XAML
|
||||
|
||||
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
|
||||
try{$Form=[Windows.Markup.XamlReader]::Load( $reader )}
|
||||
$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
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
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."
|
||||
}
|
||||
}
|
||||
|
||||
#===========================================================================
|
||||
# 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{
|
||||
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
|
||||
get-variable WPF*
|
||||
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 }
|
||||
write-host "Found the following interactable elements from our form" -ForegroundColor Cyan
|
||||
get-variable WPF*
|
||||
}
|
||||
|
||||
Get-FormVariables
|
||||
@ -49,7 +50,7 @@ $WPFTab1BT.Add_Click({
|
||||
$WPFTabNav.Items[1].IsSelected = $false
|
||||
$WPFTabNav.Items[2].IsSelected = $false
|
||||
$WPFTabNav.Items[3].IsSelected = $false
|
||||
})
|
||||
})
|
||||
$WPFTab2BT.Add_Click({
|
||||
$WPFTabNav.Items[0].IsSelected = $false
|
||||
$WPFTabNav.Items[1].IsSelected = $true
|
||||
@ -380,10 +381,13 @@ $WPFinstall.Add_Click({
|
||||
|
||||
# Check 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"
|
||||
}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
|
||||
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 ".\b0a0692da1034339b76dce1c298a1e42_License1.xml" -Force
|
||||
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)"
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
#Installing Winget from the Microsoft Store
|
||||
Write-Host "Winget not found, installing it now."
|
||||
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
|
||||
@ -425,8 +432,7 @@ $WPFinstall.Add_Click({
|
||||
$wingetinstall.ToArray()
|
||||
# Define Output variable
|
||||
$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
|
||||
$wingetResult.Add("$node`n")
|
||||
}
|
||||
@ -439,9 +445,9 @@ $WPFinstall.Add_Click({
|
||||
$Messageboxbody = ($wingetResult)
|
||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
$WPFInstallUpgrade.Add_Click({
|
||||
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")
|
||||
$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
|
||||
@ -475,7 +481,7 @@ $WPFdesktop.Add_Click({
|
||||
$WPFMiscTweaksNum.IsChecked = $true
|
||||
$WPFMiscTweaksLapPower.IsChecked = $false
|
||||
$WPFMiscTweaksLapNum.IsChecked = $false
|
||||
})
|
||||
})
|
||||
|
||||
$WPFlaptop.Add_Click({
|
||||
|
||||
@ -495,7 +501,7 @@ $WPFlaptop.Add_Click({
|
||||
$WPFMiscTweaksLapNum.IsChecked = $true
|
||||
$WPFMiscTweaksPower.IsChecked = $false
|
||||
$WPFMiscTweaksNum.IsChecked = $false
|
||||
})
|
||||
})
|
||||
|
||||
$WPFminimal.Add_Click({
|
||||
|
||||
@ -515,7 +521,7 @@ $WPFminimal.Add_Click({
|
||||
$WPFMiscTweaksNum.IsChecked = $false
|
||||
$WPFMiscTweaksLapPower.IsChecked = $false
|
||||
$WPFMiscTweaksLapNum.IsChecked = $false
|
||||
})
|
||||
})
|
||||
|
||||
$WPFtweaksbutton.Add_Click({
|
||||
|
||||
@ -757,7 +763,8 @@ $WPFtweaksbutton.Add_Click({
|
||||
Stop-Process $taskmgr
|
||||
$preferences.Preferences[28] = 0
|
||||
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..."
|
||||
If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager")) {
|
||||
@ -876,7 +883,7 @@ $WPFtweaksbutton.Add_Click({
|
||||
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 "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\Keyboard" -Name "KeyboardDelay" -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"
|
||||
|
||||
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
|
||||
Write-Host "Trying to remove $Bloat."
|
||||
}
|
||||
@ -996,8 +1003,8 @@ $WPFtweaksbutton.Add_Click({
|
||||
$Messageboxbody = ("Done")
|
||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
||||
})
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||
})
|
||||
#===========================================================================
|
||||
# Undo All
|
||||
#===========================================================================
|
||||
@ -1114,7 +1121,7 @@ $WPFundoall.Add_Click({
|
||||
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 "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\Keyboard" -Name "KeyboardDelay" -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")
|
||||
$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
|
||||
#===========================================================================
|
||||
@ -1185,60 +1192,60 @@ $WPFFeatureInstall.Add_Click({
|
||||
$Messageboxbody = ("Done")
|
||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
||||
})
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||
})
|
||||
|
||||
$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 "DISM" -ForegroundColor Green; DISM /Online /Cleanup-Image /Restorehealth;
|
||||
Write-Host "SFC - 2nd scan" -ForegroundColor Green; sfc /scannow;
|
||||
Read-Host "Press Enter"' -verb runas
|
||||
})
|
||||
})
|
||||
|
||||
$WPFPanelcontrol.Add_Click({
|
||||
cmd /c control
|
||||
})
|
||||
cmd /c control
|
||||
})
|
||||
$WPFPanelnetwork.Add_Click({
|
||||
cmd /c ncpa.cpl
|
||||
})
|
||||
cmd /c ncpa.cpl
|
||||
})
|
||||
$WPFPanelpower.Add_Click({
|
||||
cmd /c powercfg.cpl
|
||||
})
|
||||
cmd /c powercfg.cpl
|
||||
})
|
||||
$WPFPanelsound.Add_Click({
|
||||
cmd /c mmsys.cpl
|
||||
})
|
||||
cmd /c mmsys.cpl
|
||||
})
|
||||
$WPFPanelsystem.Add_Click({
|
||||
cmd /c sysdm.cpl
|
||||
})
|
||||
cmd /c sysdm.cpl
|
||||
})
|
||||
$WPFPaneluser.Add_Click({
|
||||
cmd /c "control userpasswords2"
|
||||
})
|
||||
cmd /c "control userpasswords2"
|
||||
})
|
||||
#===========================================================================
|
||||
# Tab 4 - Updates Buttons
|
||||
#===========================================================================
|
||||
|
||||
$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
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$ErrorActionPreference = 'Stop'
|
||||
trap {
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$ErrorActionPreference = 'Stop'
|
||||
trap {
|
||||
Write-Host
|
||||
Write-Host "ERROR: $_"
|
||||
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
|
||||
Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1')
|
||||
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$', 'ERROR: $1')
|
||||
Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$', 'ERROR EXCEPTION: $1')
|
||||
Write-Host
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
# disable automatic updates.
|
||||
# XXX this does not seem to work anymore.
|
||||
# see How to configure automatic updates by using Group Policy or registry settings
|
||||
# at https://support.microsoft.com/en-us/help/328010
|
||||
function New-Directory($path) {
|
||||
# disable automatic updates.
|
||||
# XXX this does not seem to work anymore.
|
||||
# see How to configure automatic updates by using Group Policy or registry settings
|
||||
# at https://support.microsoft.com/en-us/help/328010
|
||||
function New-Directory($path) {
|
||||
$p, $components = $path -split '[\\/]'
|
||||
$components | ForEach-Object {
|
||||
$p = "$p\$_"
|
||||
@ -1247,25 +1254,25 @@ function New-Directory($path) {
|
||||
}
|
||||
}
|
||||
$null
|
||||
}
|
||||
$auPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
|
||||
New-Directory $auPath
|
||||
# set NoAutoUpdate.
|
||||
# 0: Automatic Updates is enabled (default).
|
||||
# 1: Automatic Updates is disabled.
|
||||
New-ItemProperty `
|
||||
}
|
||||
$auPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
|
||||
New-Directory $auPath
|
||||
# set NoAutoUpdate.
|
||||
# 0: Automatic Updates is enabled (default).
|
||||
# 1: Automatic Updates is disabled.
|
||||
New-ItemProperty `
|
||||
-Path $auPath `
|
||||
-Name NoAutoUpdate `
|
||||
-Value 0 `
|
||||
-PropertyType DWORD `
|
||||
-Force `
|
||||
| Out-Null
|
||||
# set AUOptions.
|
||||
# 1: Keep my computer up to date has been disabled in Automatic Updates.
|
||||
# 2: Notify of download and installation.
|
||||
# 3: Automatically download and notify of installation.
|
||||
# 4: Automatically download and scheduled installation.
|
||||
New-ItemProperty `
|
||||
# set AUOptions.
|
||||
# 1: Keep my computer up to date has been disabled in Automatic Updates.
|
||||
# 2: Notify of download and installation.
|
||||
# 3: Automatically download and notify of installation.
|
||||
# 4: Automatically download and scheduled installation.
|
||||
New-ItemProperty `
|
||||
-Path $auPath `
|
||||
-Name AUOptions `
|
||||
-Value 3 `
|
||||
@ -1273,13 +1280,13 @@ New-ItemProperty `
|
||||
-Force `
|
||||
| Out-Null
|
||||
|
||||
# disable Windows Update Delivery Optimization.
|
||||
# NB this applies to Windows 10.
|
||||
# 0: Disabled
|
||||
# 1: PCs on my local network
|
||||
# 3: PCs on my local network, and PCs on the Internet
|
||||
$deliveryOptimizationPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config'
|
||||
If (Test-Path $deliveryOptimizationPath) {
|
||||
# disable Windows Update Delivery Optimization.
|
||||
# NB this applies to Windows 10.
|
||||
# 0: Disabled
|
||||
# 1: PCs on my local network
|
||||
# 3: PCs on my local network, and PCs on the Internet
|
||||
$deliveryOptimizationPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config'
|
||||
If (Test-Path $deliveryOptimizationPath) {
|
||||
New-ItemProperty `
|
||||
-Path $deliveryOptimizationPath `
|
||||
-Name DODownloadMode `
|
||||
@ -1287,20 +1294,20 @@ If (Test-Path $deliveryOptimizationPath) {
|
||||
-PropertyType DWORD `
|
||||
-Force `
|
||||
| Out-Null
|
||||
}
|
||||
# Service tweaks for Windows Update
|
||||
}
|
||||
# Service tweaks for Windows Update
|
||||
|
||||
$services = @(
|
||||
$services = @(
|
||||
"BITS"
|
||||
"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
|
||||
|
||||
Write-Host "Setting $service StartupType to Automatic"
|
||||
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Automatic
|
||||
}
|
||||
}
|
||||
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\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 "DeferFeatureUpdatesPeriodInDays" -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferQualityUpdatesPeriodInDays " -ErrorAction SilentlyContinue
|
||||
})
|
||||
})
|
||||
$WPFFixesUpdate.Add_Click({
|
||||
### Reset Windows Update Script - reregister dlls, services, and remove registry entires.
|
||||
Write-Host "1. Stopping Windows Update Services..."
|
||||
@ -1394,7 +1401,8 @@ $WPFFixesUpdate.Add_Click({
|
||||
Write-Host "10) Attempting to install the Windows Update Agent..."
|
||||
If ($arch -eq 64) {
|
||||
wusa Windows8-RT-KB2937636-x64 /quiet
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
wusa Windows8-RT-KB2937636-x86 /quiet
|
||||
}
|
||||
|
||||
@ -1414,29 +1422,29 @@ $WPFFixesUpdate.Add_Click({
|
||||
$Messageboxbody = ("Stock settings loaded.`n Please reboot your computer")
|
||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
||||
})
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||
})
|
||||
$WPFUpdatesdisable.Add_Click({
|
||||
# Source: https://github.com/rgl/windows-vagrant/blob/master/disable-windows-updates.ps1
|
||||
Set-StrictMode -Version Latest
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$ErrorActionPreference = 'Stop'
|
||||
trap {
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$ErrorActionPreference = 'Stop'
|
||||
trap {
|
||||
Write-Host
|
||||
Write-Host "ERROR: $_"
|
||||
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
|
||||
Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1')
|
||||
Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$', 'ERROR: $1')
|
||||
Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$', 'ERROR EXCEPTION: $1')
|
||||
Write-Host
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
# disable automatic updates.
|
||||
# XXX this does not seem to work anymore.
|
||||
# see How to configure automatic updates by using Group Policy or registry settings
|
||||
# at https://support.microsoft.com/en-us/help/328010
|
||||
function New-Directory($path) {
|
||||
# disable automatic updates.
|
||||
# XXX this does not seem to work anymore.
|
||||
# see How to configure automatic updates by using Group Policy or registry settings
|
||||
# at https://support.microsoft.com/en-us/help/328010
|
||||
function New-Directory($path) {
|
||||
$p, $components = $path -split '[\\/]'
|
||||
$components | ForEach-Object {
|
||||
$p = "$p\$_"
|
||||
@ -1445,25 +1453,25 @@ function New-Directory($path) {
|
||||
}
|
||||
}
|
||||
$null
|
||||
}
|
||||
$auPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
|
||||
New-Directory $auPath
|
||||
# set NoAutoUpdate.
|
||||
# 0: Automatic Updates is enabled (default).
|
||||
# 1: Automatic Updates is disabled.
|
||||
New-ItemProperty `
|
||||
}
|
||||
$auPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
|
||||
New-Directory $auPath
|
||||
# set NoAutoUpdate.
|
||||
# 0: Automatic Updates is enabled (default).
|
||||
# 1: Automatic Updates is disabled.
|
||||
New-ItemProperty `
|
||||
-Path $auPath `
|
||||
-Name NoAutoUpdate `
|
||||
-Value 1 `
|
||||
-PropertyType DWORD `
|
||||
-Force `
|
||||
| Out-Null
|
||||
# set AUOptions.
|
||||
# 1: Keep my computer up to date has been disabled in Automatic Updates.
|
||||
# 2: Notify of download and installation.
|
||||
# 3: Automatically download and notify of installation.
|
||||
# 4: Automatically download and scheduled installation.
|
||||
New-ItemProperty `
|
||||
# set AUOptions.
|
||||
# 1: Keep my computer up to date has been disabled in Automatic Updates.
|
||||
# 2: Notify of download and installation.
|
||||
# 3: Automatically download and notify of installation.
|
||||
# 4: Automatically download and scheduled installation.
|
||||
New-ItemProperty `
|
||||
-Path $auPath `
|
||||
-Name AUOptions `
|
||||
-Value 1 `
|
||||
@ -1471,13 +1479,13 @@ New-ItemProperty `
|
||||
-Force `
|
||||
| Out-Null
|
||||
|
||||
# disable Windows Update Delivery Optimization.
|
||||
# NB this applies to Windows 10.
|
||||
# 0: Disabled
|
||||
# 1: PCs on my local network
|
||||
# 3: PCs on my local network, and PCs on the Internet
|
||||
$deliveryOptimizationPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config'
|
||||
If (Test-Path $deliveryOptimizationPath) {
|
||||
# disable Windows Update Delivery Optimization.
|
||||
# NB this applies to Windows 10.
|
||||
# 0: Disabled
|
||||
# 1: PCs on my local network
|
||||
# 3: PCs on my local network, and PCs on the Internet
|
||||
$deliveryOptimizationPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config'
|
||||
If (Test-Path $deliveryOptimizationPath) {
|
||||
New-ItemProperty `
|
||||
-Path $deliveryOptimizationPath `
|
||||
-Name DODownloadMode `
|
||||
@ -1485,22 +1493,22 @@ If (Test-Path $deliveryOptimizationPath) {
|
||||
-PropertyType DWORD `
|
||||
-Force `
|
||||
| Out-Null
|
||||
}
|
||||
# Service tweaks for Windows Update
|
||||
}
|
||||
# Service tweaks for Windows Update
|
||||
|
||||
$services = @(
|
||||
$services = @(
|
||||
"BITS"
|
||||
"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
|
||||
|
||||
Write-Host "Setting $service StartupType to Disabled"
|
||||
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Disabled
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
$WPFUpdatessecurity.Add_Click({
|
||||
Write-Host "Disabling driver offering through Windows Update..."
|
||||
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata")) {
|
||||
@ -1533,8 +1541,8 @@ $WPFUpdatessecurity.Add_Click({
|
||||
$Messageboxbody = ("Recommended Update settings loaded")
|
||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$MessageIcon)
|
||||
})
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||
})
|
||||
|
||||
#===========================================================================
|
||||
# Shows the form
|
||||
|
Loading…
Reference in New Issue
Block a user