mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-02-04 15:00:09 +00:00
Update-docs (#3889)
* Update _index.md * Rename AH.md to Activity.md * Update Activity.md * Update Activity.md * Update Activity.md * Update ConsumerFeatures.md * Update and rename DVR.md to GameDVR.md * Update DeleteTempFiles.md * Delete docs/content/dev/tweaks/Essential-Tweaks/DisableRecall.md * Update _index.md * Update _index.md * Update DiskCleanup.md * Update EdgeDebloat.md * Update Activity.md * Update EndTaskOnTaskbar.md * Update ConsumerFeatures.md * Update GameDVR.md * Update and rename Hiber.md to Hibernation.md * Delete docs/content/dev/tweaks/Essential-Tweaks/Home.md * Update IPv46.md * Update LaptopHibernation.md * Update and rename Loc.md to Location.md * Delete docs/content/dev/tweaks/Essential-Tweaks/Powershell7.md * Update Powershell7Tele.md * Update RestorePoint.md * Update Services.md * Update Storage.md * Update Tele.md * Rename Tele.md to Telemetry.md * Delete docs/content/dev/tweaks/Essential-Tweaks/Wifi.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update and rename RemoveUltPerf.md to RemoveProfile.md * Delete docs/content/dev/tweaks/Performance-Plans/AddUltPerf.md * Rename RemoveProfile.md to Profile.md * Update _index.md * Update _index.md * Update _index.md * Update BingSearch.md * Update DarkMode.md * Update DetailedBSoD.md * Update HiddenFiles.md * Update MouseAcceleration.md * Update NumLock.md * Update ShowExt.md * Update SnapFlyout.md * Update SnapSuggestion.md * Update SnapWindow.md * Update StickyKeys.md * Update TaskView.md * Update TaskbarAlignment.md * Update TaskbarSearch.md * Update TaskbarWidgets.md * Update VerboseLogon.md * Update _index.md * Update _index.md * Update _index.md * Update BlockAdobeNet.md * Update DeBloat.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/DebloatAdobe.md * Update DisableBGapps.md * Update DisableFSO.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/DisableLMS1.md * Update DisableNotifications.md * Update and rename Disableipsix.md to DisableIPv6.md * Update Display.md * Update OOSUbutton.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/RemoveCopilot.md * Update and rename RemoveEdge.md to EdgeUninstall.md * Update and rename RemoveHomeGallery.md to RemoveHome.md * Create RemoveGallery.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/RemoveOnedrive.md * Update RightClickMenu.md * Update Teredo.md * Update UTC.md * Update Undoall.md * Update button.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/changedns.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/button.md * Delete docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/Undoall.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update DisableLegacyRecovery.md * Delete docs/content/dev/features/Features/DisableSearchSuggestions.md * Update EnableLegacyRecovery.md * Update DisableLegacyRecovery.md * Delete docs/content/dev/features/Features/EnableSearchSuggestions.md * Delete docs/content/dev/features/Features/Install.md * Update RegBackup.md * Update Sandbox.md * Update dotnet.md * Update hyperv.md * Update legacymedia.md * Update nfs.md * Update wsl.md * Update _index.md * Update _index.md * Update _index.md * Update Autologin.md * Update and rename DISM.md to CorruptionScan.md * Update Network.md * Update RunAdobeCCCleanerTool.md * Update Update.md * Update Winget.md * Update _index.md * Update _index.md * Update _index.md * Update control.md * Update network.md * Update power.md * Update printer.md * Update region.md * Update sound.md * Update system.md * Update user.md * Update _index.md * Update _index.md * Update _index.md * Delete docs/assets/images/Compile.png * Add files via upload * Update KnownIssues.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Update _index.md * Delete docs/archetypes directory * Delete docs/i18n directory * Delete docs/assets/images/Install/Installation-completion.png * Delete docs/assets/images/Install/track-progress.png * Delete docs/assets/images/microwin/dism++_drivercontrol.png * Delete docs/assets/images/microwin/dism++_driverexport.png * Delete docs/assets/images/microwin/dt_activeinst.png * Delete docs/assets/images/microwin/dt_exportdrvs.png * Delete docs/assets/images/microwin/dt_exporttarget.png * Rename microwin-customuser-dark.png to microwin-user-dark.png * Rename microwin-customuser-light.png to microwin-user-light.png * Delete docs/assets/images/microwin/microwin-downloader-dark.png * Delete docs/assets/images/microwin/microwin-downloader-light.png * Delete docs/assets/images/microwin/microwin-screen-dark.png * Delete docs/assets/images/microwin/microwin-screen-full-dark.png * Delete docs/assets/images/microwin/microwin-screen-full-light.png * Delete docs/assets/images/microwin/microwin-screen-light.png * Delete docs/assets/images/microwin/microwin-skuselect-dark.png * Delete docs/assets/images/microwin/microwin-skuselect-light.png * Delete docs/assets/images/microwin/microwin-user-dark.png * Delete docs/assets/images/microwin/microwin-user-light.png * Delete docs/assets/images/microwin/rapr_folderpicker.png * Delete docs/assets/images/microwin/rapr_menu.png * Create 4 * Add files via upload * Delete docs/assets/images/microwin/4 * Delete docs/assets/images/microwin/Configure-Windows-ISO.png * Add files via upload * Delete docs/assets/images/microwin/Configure-Windows-ISO.png * Add files via upload * Create default.md * Fix formatting in automation user guide * Fix typo in Edge uninstall link text * Fix typo in DeBloat.md description Corrected a typo in the description of the WPFTweaksDeBloat section. * Update links for Delete Temp Files and Activity History * fix bad urls * update typos --------- Co-authored-by: Chris Titus <contact@christitus.com>
This commit is contained in:
141
docs/content/dev/features/Fixes/CorruptionScan.md
Normal file
141
docs/content/dev/features/Fixes/CorruptionScan.md
Normal file
@@ -0,0 +1,141 @@
|
||||
# System Corruption Scan
|
||||
|
||||
```json
|
||||
function Invoke-WPFSystemRepair {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks for system corruption using Chkdsk, SFC, and DISM
|
||||
|
||||
.DESCRIPTION
|
||||
1. Chkdsk - Fixes disk and filesystem corruption
|
||||
2. SFC Run 1 - Fixes system file corruption, and fixes DISM if it was corrupted
|
||||
3. DISM - Fixes system image corruption, and fixes SFC's system image if it was corrupted
|
||||
4. SFC Run 2 - Fixes system file corruption, this time with an almost guaranteed uncorrupted system image
|
||||
#>
|
||||
|
||||
function Invoke-Chkdsk {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Runs chkdsk on the system drive
|
||||
.DESCRIPTION
|
||||
Chkdsk /Scan - Runs an online scan on the system drive, attempts to fix any corruption, and queues other corruption for fixing on reboot
|
||||
#>
|
||||
param(
|
||||
[int]$parentProgressId = 0
|
||||
)
|
||||
|
||||
Write-Progress -Id 1 -ParentId $parentProgressId -Activity $childProgressBarActivity -Status "Running chkdsk..." -PercentComplete 0
|
||||
$oldpercent = 0
|
||||
# 2>&1 redirects stdout, allowing iteration over the output
|
||||
chkdsk.exe /scan /perf 2>&1 | ForEach-Object {
|
||||
Write-Debug $_
|
||||
# Regex to match the total percentage regardless of windows locale (it's always the second percentage in the status output)
|
||||
if ($_ -match "%.*?(\d+)%") {
|
||||
[int]$percent = $matches[1]
|
||||
if ($percent -gt $oldpercent) {
|
||||
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "Running chkdsk... ($percent%)" -PercentComplete $percent
|
||||
$oldpercent = $percent
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "chkdsk Completed" -PercentComplete 100 -Completed
|
||||
}
|
||||
|
||||
function Invoke-SFC {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Runs sfc on the system drive
|
||||
.DESCRIPTION
|
||||
SFC /ScanNow - Performs a scan of the system files and fixes any corruption
|
||||
.NOTES
|
||||
ErrorActionPreference is set locally within a script block & {...} to isolate their effects.
|
||||
ErrorActionPreference suppresses false errors caused by sfc.exe output redirection.
|
||||
A bug in SFC output buffering causes progress updates to appear in chunks when redirecting output
|
||||
#>
|
||||
param(
|
||||
[int]$parentProgressId = 0
|
||||
)
|
||||
& {
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
Write-Progress -Id 1 -ParentId $parentProgressId -Activity $childProgressBarActivity -Status "Running SFC..." -PercentComplete 0
|
||||
$oldpercent = 0
|
||||
sfc.exe /scannow 2>&1 | ForEach-Object {
|
||||
Write-Debug $_
|
||||
if ($_ -ne "") {
|
||||
# sfc.exe /scannow outputs unicode characters, so we directly remove null characters for optimization
|
||||
$utf8line = $_ -replace "`0", ""
|
||||
if ($utf8line -match "(\d+)\s*%") {
|
||||
[int]$percent = $matches[1]
|
||||
if ($percent -gt $oldpercent) {
|
||||
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "Running SFC... ($percent%)" -PercentComplete $percent
|
||||
$oldpercent = $percent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "SFC Completed" -PercentComplete 100 -Completed
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-DISM {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Runs DISM on the system drive
|
||||
.DESCRIPTION
|
||||
DISM - Fixes system image corruption, and fixes SFC's system image if it was corrupted
|
||||
/Online - Fixes the currently running system image
|
||||
/Cleanup-Image - Performs cleanup operations on the image, could remove some unneeded temporary files
|
||||
/Restorehealth - Performs a scan of the image and fixes any corruption
|
||||
#>
|
||||
param(
|
||||
[int]$parentProgressId = 0
|
||||
)
|
||||
Write-Progress -Id 1 -ParentId $parentProgressId -Activity $childProgressBarActivity -Status "Running DISM..." -PercentComplete 0
|
||||
$oldpercent = 0
|
||||
DISM /Online /Cleanup-Image /RestoreHealth | ForEach-Object {
|
||||
Write-Debug $_
|
||||
# Filter for lines that contain a percentage that is greater than the previous one
|
||||
if ($_ -match "(\d+)[.,]\d+%") {
|
||||
[int]$percent = $matches[1]
|
||||
if ($percent -gt $oldpercent) {
|
||||
# Update the progress bar
|
||||
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "Running DISM... ($percent%)" -PercentComplete $percent
|
||||
$oldpercent = $percent
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Progress -Id 1 -Activity $childProgressBarActivity -Status "DISM Completed" -PercentComplete 100 -Completed
|
||||
}
|
||||
|
||||
try {
|
||||
Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo"
|
||||
|
||||
$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 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"
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user