- diagnostics/ 11 个:环境/配置/依赖诊断 - logs/ 7 个:日志分析与查看 - coords/ 6 个:坐标拾取与区域选择 - cleanup/ 3 个:代码清理工具 - adb/ 2 个:ADB / 输入法相关 - windows/ 4 个:Windows 系统修复(备份) - dev/ 9 个:开发辅助 / 运行时探测 并更新 tools/README.md 描述新结构。 删除 3 个明显的临时调试脚本 (_dump_lines.py / tmp_*.py)。 tools/ 不被业务代码 import,分组仅为人工浏览方便。 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
82 lines
3.2 KiB
PowerShell
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
|
|
}
|