Files
douyin_guaji-main/tools/dism_restorehealth_from_iso.ps1
T
Your Name dcded08796 feat: enhance swipe and back navigation logic
- Adjusted configuration for reset after swipes to 10 seconds and added action to go back.
- Updated flow control to skip back action if a recent reset was triggered within 5 seconds.
- Implemented a mechanism to enable back navigation when consecutive misses reach a threshold.
- Added GUI options to enable or disable back navigation on misses, ensuring consistency with user settings.
- Introduced new diagnostic tools for runtime flag checks and screenshot diagnostics.
- Created PowerShell scripts for restoring Start Menu shortcuts and performing system health checks.
- Added tests for swipe operations and back navigation to validate new logic.
2026-01-06 16:55:00 +08:00

88 lines
2.3 KiB
PowerShell

[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$IsoPath,
[int]$Index = 0,
[switch]$NoUnmount
)
$ErrorActionPreference = 'Stop'
function Write-Section([string]$title) {
Write-Host ""
Write-Host "=== $title ==="
}
function Test-IsAdmin {
$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
if (!(Test-IsAdmin)) {
throw 'Please run this script as Administrator.'
}
$isoFull = (Resolve-Path $IsoPath).Path
if (!(Test-Path -LiteralPath $isoFull)) {
throw "ISO not found: $isoFull"
}
Write-Section 'Mount ISO'
Write-Host "ISO: $isoFull"
$disk = Mount-DiskImage -ImagePath $isoFull -PassThru
Start-Sleep -Seconds 1
$vol = ($disk | Get-Volume | Select-Object -First 1)
if ($null -eq $vol -or [string]::IsNullOrWhiteSpace($vol.DriveLetter)) {
throw 'Failed to get mounted ISO drive letter.'
}
$drive = ($vol.DriveLetter + ':')
Write-Host "Mounted drive: $drive"
try {
Write-Section 'Locate install.wim/install.esd'
$wim = Join-Path $drive 'sources\install.wim'
$esd = Join-Path $drive 'sources\install.esd'
$imagePath = $null
if (Test-Path -LiteralPath $wim) { $imagePath = $wim }
elseif (Test-Path -LiteralPath $esd) { $imagePath = $esd }
else { throw 'install.wim/install.esd not found under sources\\' }
Write-Host "Image: $imagePath"
Write-Section 'Show available indexes'
dism /English /Get-WimInfo /WimFile:"$imagePath"
if ($Index -le 0) {
Write-Host "\nIndex is 0: please re-run with -Index <number> matching your edition (e.g. Pro/Home)."
return
}
Write-Section 'DISM RestoreHealth (from ISO source)'
Write-Host "Using Index: $Index"
$sourceArg = if ($imagePath.ToLowerInvariant().EndsWith('.wim')) {
"wim:$imagePath:$Index"
} else {
"esd:$imagePath:$Index"
}
dism /Online /Cleanup-Image /RestoreHealth /Source:$sourceArg /LimitAccess
Write-Section 'SFC Scannow'
sfc /scannow
Write-Host '\nDone. Reboot recommended.'
}
finally {
if (-not $NoUnmount) {
Write-Section 'Unmount ISO'
Dismount-DiskImage -ImagePath $isoFull -ErrorAction SilentlyContinue
} else {
Write-Host 'NoUnmount set; ISO left mounted.'
}
}