Files
douyin_guaji-main/tools/fix_start_menu_win11_admin.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

82 lines
3.2 KiB
PowerShell

[CmdletBinding()]
param(
[switch]$SkipDism,
[switch]$SkipSfc,
[switch]$SkipAppx
)
$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)
}
$now = Get-Date -Format 'yyyyMMdd_HHmmss'
$logPath = Join-Path ([Environment]::GetFolderPath('Desktop')) "StartMenuFix_Admin_$now.log"
"StartMenuFix Admin started: $(Get-Date)" | Out-File -FilePath $logPath -Encoding UTF8
"Running as admin: $(Test-IsAdmin)" | Out-File -FilePath $logPath -Append -Encoding UTF8
if (!(Test-IsAdmin)) {
"ERROR: This script must be run as Administrator." | Out-File -FilePath $logPath -Append -Encoding UTF8
throw 'This script must be run as Administrator.'
}
Write-Host "Log: $logPath"
try {
if (-not $SkipDism) {
Write-Section 'DISM RestoreHealth'
"DISM start: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
DISM /Online /Cleanup-Image /RestoreHealth | Out-File -FilePath $logPath -Append -Encoding UTF8
"DISM end: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
}
if (-not $SkipSfc) {
Write-Section 'SFC Scannow'
"SFC start: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
sfc /scannow | Out-File -FilePath $logPath -Append -Encoding UTF8
"SFC end: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
}
if (-not $SkipAppx) {
Write-Section 'Re-register AppX (All Users)'
"AppX re-register start: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
Get-AppxPackage -AllUsers | ForEach-Object {
$manifest = Join-Path $_.InstallLocation 'AppxManifest.xml'
if (Test-Path $manifest) {
try {
Add-AppxPackage -DisableDevelopmentMode -Register $manifest -ErrorAction Stop | Out-Null
} catch {
# Keep going; capture error into log for diagnostics
"WARN: $($_.Name) - $($_.Exception.Message)" | Out-File -FilePath $logPath -Append -Encoding UTF8
}
}
}
"AppX re-register end: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
}
Write-Section 'Restart Explorer'
"Restart explorer: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
Get-Process -Name StartMenuExperienceHost -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process -Name ShellExperienceHost -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process -Name explorer -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -Milliseconds 600
Start-Process explorer.exe
"DONE: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
Write-Host 'Done. Explorer restarted.'
Write-Host "Log saved: $logPath"
} catch {
"FATAL: $($_.Exception.Message)" | Out-File -FilePath $logPath -Append -Encoding UTF8
throw
}