mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-27 16:44:46 -05:00
[Fixes] Improve Error Handling + UI (#3437)
* add proper error handling + Taskbaritem support to WPFSystemRepair * implement other fixes - add Taskbarprogress to WPFFixesNetwork - add Taskbarprogress to WPFFixesUpdate - add Error handling + Taskbarprogress to WPFFixesWinget - add finalisation in WPFSystemRepair
This commit is contained in:
@ -8,13 +8,20 @@ function Invoke-WPFFixesNetwork {
|
||||
|
||||
Write-Host "Resetting Network with netsh"
|
||||
|
||||
Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo"
|
||||
# Reset WinSock catalog to a clean state
|
||||
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winsock", "reset"
|
||||
|
||||
Set-WinUtilTaskbaritem -state "Normal" -value 0.35 -overlay "logo"
|
||||
# Resets WinHTTP proxy setting to DIRECT
|
||||
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winhttp", "reset", "proxy"
|
||||
|
||||
Set-WinUtilTaskbaritem -state "Normal" -value 0.7 -overlay "logo"
|
||||
# Removes all user configured IP settings
|
||||
Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "int", "ip", "reset"
|
||||
|
||||
Set-WinUtilTaskbaritem -state "None" -overlay "checkmark"
|
||||
|
||||
Write-Host "Process complete. Please reboot your computer."
|
||||
|
||||
$ButtonType = [System.Windows.MessageBoxButton]::OK
|
||||
|
@ -30,6 +30,8 @@ function Invoke-WPFFixesUpdate {
|
||||
param($Aggressive = $false)
|
||||
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows Update" -PercentComplete 0
|
||||
Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo"
|
||||
Write-Host "Starting Windows Update Repair..."
|
||||
# Wait for the first progress bar to show, otherwise the second one won't show
|
||||
Start-Sleep -Milliseconds 200
|
||||
|
||||
@ -190,12 +192,15 @@ function Invoke-WPFFixesUpdate {
|
||||
try {
|
||||
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
|
||||
} catch {
|
||||
Set-WinUtilTaskbaritem -state "Error" -overlay "warning"
|
||||
Write-Warning "Failed to create Windows Update COM object: $_"
|
||||
}
|
||||
Start-Process -NoNewWindow -FilePath "wuauclt" -ArgumentList "/resetauthorization", "/detectnow"
|
||||
Write-Progress -Id 10 -ParentId 0 -Activity "Forcing discovery" -Status "Completed" -PercentComplete 100
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows Update" -Status "Completed" -PercentComplete 100
|
||||
|
||||
Set-WinUtilTaskbaritem -state "None" -overlay "checkmark"
|
||||
|
||||
$ButtonType = [System.Windows.MessageBoxButton]::OK
|
||||
$MessageboxTitle = "Reset Windows Update "
|
||||
$Messageboxbody = ("Stock settings loaded.`n Please reboot your computer")
|
||||
|
@ -8,7 +8,16 @@ function Invoke-WPFFixesWinget {
|
||||
BravoNorris for the fantastic idea of a button to reinstall winget
|
||||
#>
|
||||
# Install Choco if not already present
|
||||
Install-WinUtilChoco
|
||||
Start-Process -FilePath "choco" -ArgumentList "install winget -y --force" -NoNewWindow -Wait
|
||||
try {
|
||||
Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo"
|
||||
Install-WinUtilChoco
|
||||
Start-Process -FilePath "choco" -ArgumentList "install winget -y --force" -NoNewWindow -Wait
|
||||
} catch {
|
||||
Write-Error "Failed to install winget: $_"
|
||||
Set-WinUtilTaskbaritem -state "Error" -overlay "warning"
|
||||
} finally {
|
||||
Write-Host "==> Finished Winget Repair"
|
||||
Set-WinUtilTaskbaritem -state "None" -overlay "checkmark"
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -104,21 +104,34 @@ function Invoke-WPFSystemRepair {
|
||||
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "DISM Completed" -PercentComplete 100 -Completed
|
||||
}
|
||||
|
||||
$childProgressBarActivity = "Scanning for corruption"
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 0
|
||||
# Step 1: Run chkdsk to fix disk and filesystem corruption before proceeding with system file repairs
|
||||
Invoke-Chkdsk
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 25
|
||||
try {
|
||||
Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo"
|
||||
|
||||
# Step 2: Run SFC to fix system file corruption and ensure DISM can operate correctly
|
||||
Invoke-SFC
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 50
|
||||
$childProgressBarActivity = "Scanning for corruption"
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 0
|
||||
# Step 1: Run chkdsk to fix disk and filesystem corruption before proceeding with system file repairs
|
||||
Invoke-Chkdsk
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 25
|
||||
|
||||
# Step 3: Run DISM to repair the system image, which SFC relies on for accurate repairs
|
||||
Invoke-DISM
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 75
|
||||
# Step 2: Run SFC to fix system file corruption and ensure DISM can operate correctly
|
||||
Invoke-SFC
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 50
|
||||
|
||||
# Step 3: Run DISM to repair the system image, which SFC relies on for accurate repairs
|
||||
Invoke-DISM
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 75
|
||||
|
||||
# Step 4: Run SFC again to ensure system files are repaired using the now-fixed system image
|
||||
Invoke-SFC
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 100 -Completed
|
||||
|
||||
Set-WinUtilTaskbaritem -state "None" -overlay "checkmark"
|
||||
} catch {
|
||||
Write-Error "An error occurred while repairing the system: $_"
|
||||
Set-WinUtilTaskbaritem -state "Error" -overlay "warning"
|
||||
} finally {
|
||||
Write-Host "==> Finished System Repair"
|
||||
Set-WinUtilTaskbaritem -state "None" -overlay "checkmark"
|
||||
}
|
||||
|
||||
# Step 4: Run SFC again to ensure system files are repaired using the now-fixed system image
|
||||
Invoke-SFC
|
||||
Write-Progress -Id 0 -Activity "Repairing Windows" -PercentComplete 100 -Completed
|
||||
}
|
||||
|
Reference in New Issue
Block a user