This PowerShell script is designed to perform a comprehensive system check and repair on Windows 10 and 11. It goes through multiple stages to check for errors, repair system files, reset Windows Update components, clean temporary files, and more. Here's what the script does:
This script is helpful for fixing common Windows issues, improving system stability, and ensuring the system components are functioning properly.
Этот скрипт PowerShell предназначен для выполнения проверки и ремонта системы на Windows 10 и 11. Он проходит через несколько этапов, чтобы проверить наличие ошибок, отремонтировать системные файлы, сбросить компоненты Windows Update, очистить временные файлы и многое другое. Вот что делает скрипт:
Этот скрипт полезен для устранения общих проблем Windows, повышения стабильности системы и обеспечения правильной работы системных компонентов.
WinFix.exe - фикс системы
FixOffline.zip - фикс целевой системый из WinPE - chkdsk системного раздела и Dism
OfflineSFC.exe - Offline SFC Fixer для WinPEx64 - обновленный вариант!
- Check Disk for Errors:
It scans the C: drive for file system errors. If errors are found, the script prompts the user to choose whether to check for bad sectors and restart the computer to fix them. - System File Checker (SFC):
Runs the sfc /scannow command to check and repair any corrupted system files. - DISM (Deployment Imaging Service and Management Tool):
It checks and repairs the Windows image using three DISM commands: ScanHealth, CheckHealth, and RestoreHealth. - Reset Windows Update Components:
Resets the Windows Update components by stopping services, renaming specific system folders, and restarting services. This is useful for fixing Windows Update problems. - Clean Up Temporary Files:
Deletes unnecessary temporary files from both the system and user directories to free up space and improve performance. - Re-register All System Apps:
Re-registers all system apps to fix any issues related to missing or corrupted system apps. - Fixing Corrupted User Profile (Optional):
Offers the user an option to create a new user profile in case the existing one is corrupted. This may require transferring data manually from the old profile to the new one. - Final Step – Restart the Computer:
At the end of the script, the user is asked whether they want to restart the computer to apply changes.
This script is helpful for fixing common Windows issues, improving system stability, and ensuring the system components are functioning properly.
Этот скрипт PowerShell предназначен для выполнения проверки и ремонта системы на Windows 10 и 11. Он проходит через несколько этапов, чтобы проверить наличие ошибок, отремонтировать системные файлы, сбросить компоненты Windows Update, очистить временные файлы и многое другое. Вот что делает скрипт:
- Проверка диска на ошибки:
Скрипт сканирует диск C: на наличие ошибок файловой системы. Если ошибки найдены, скрипт предлагает пользователю выбрать, нужно ли проверить плохие сектора, и перезагрузить компьютер для их исправления. - Проверка системных файлов с помощью SFC:
Запускает команду sfc /scannow, чтобы проверить и отремонтировать поврежденные системные файлы. - DISM (Инструмент управления развертыванием и изображениями):
Он проверяет и восстанавливает образ Windows с помощью трех команд DISM: ScanHealth, CheckHealth и RestoreHealth. - Сброс компонентов Windows Update:
Сбрасывает компоненты Windows Update, останавливая службы, переименовывая определенные системные папки и перезапуская службы. Это полезно для устранения проблем с обновлениями Windows. - Очистка временных файлов:
Удаляет ненужные временные файлы как из системной, так и из пользовательской директории, чтобы освободить место и улучшить производительность. - Перерегистрация всех системных приложений:
Перерегистрирует все системные приложения, чтобы исправить проблемы с отсутствующими или поврежденными приложениями. - Исправление поврежденного пользовательского профиля (по желанию):
Предлагает пользователю создать новый профиль пользователя в случае повреждения существующего. Для этого возможно потребуется вручную перенести данные с старого профиля в новый. - Финальный шаг — Перезагрузка компьютера:
В конце скрипта пользователю предлагается перезагрузить компьютер для применения изменений.
Этот скрипт полезен для устранения общих проблем Windows, повышения стабильности системы и обеспечения правильной работы системных компонентов.
WinFix.exe - фикс системы
FixOffline.zip - фикс целевой системый из WinPE - chkdsk системного раздела и Dism
OfflineSFC.exe - Offline SFC Fixer для WinPEx64 - обновленный вариант!
Код:
# Run as administrator
Write-Host "Starting system check and repair process..." -ForegroundColor Green
# Step 1: Check disk for errors (C: drive)
Write-Host "`nChecking disk for errors..."
$diskCheck = chkdsk C: /scan
if ($diskCheck -match "Windows has scanned the file system and found problems") {
Write-Host "`nErrors found in the file system!" -ForegroundColor Red
$fullCheckChoice = Read-Host "Do you want to check for bad sectors as well? (Y/N)"
if ($fullCheckChoice -match "[Yy]") {
$chkCommand = "chkdsk C: /f /r /x"
} else {
$chkCommand = "chkdsk C: /f /x"
}
$restartChoice = Read-Host "A restart is required to fix them. Restart now? (Y/N)"
if ($restartChoice -match "[Yy]") {
Write-Host "Scheduling CHKDSK on next reboot and restarting..." -ForegroundColor Yellow
cmd.exe /c "$chkCommand"
Restart-Computer -Force
exit
} else {
Write-Host "Skipping disk repair. Continuing with other checks..." -ForegroundColor Yellow
}
} else {
Write-Host "No file system errors found. Continuing..." -ForegroundColor Green
}
# Step 2: Check and repair system files
Write-Host "`nRunning System File Checker (SFC)..."
sfc /scannow
# Step 3: Repair Windows image
Write-Host "`nChecking Windows component store (DISM)..."
DISM /Online /Cleanup-Image /ScanHealth
DISM /Online /Cleanup-Image /CheckHealth
DISM /Online /Cleanup-Image /RestoreHealth
# Step 4: Reset Windows Update components
Write-Host "`nResetting Windows Update components..."
Stop-Service wuauserv -Force
Stop-Service cryptsvc -Force
Stop-Service bits -Force
Rename-Item -Path "C:\Windows\SoftwareDistribution" -NewName "SoftwareDistribution.old"
Rename-Item -Path "C:\Windows\System32\catroot2" -NewName "catroot2.old"
Start-Service wuauserv
Start-Service cryptsvc
Start-Service bits
Write-Host "Windows Update components have been reset." -ForegroundColor Green
# Step 5: Clean up temporary files
Write-Host "`nCleaning up temporary files..."
Remove-Item -Path "C:\Windows\Temp\*" -Recurse -Force
Remove-Item -Path "C:\Users\$env:USERNAME\AppData\Local\Temp\*" -Recurse -Force
Write-Host "Temporary files cleaned." -ForegroundColor Green
# Step 6: Re-register all system apps
Write-Host "`nRe-registering all system apps..."
Get-AppXPackage | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
Write-Host "All system apps have been re-registered." -ForegroundColor Green
# Step 7: Check and repair the system registry
Write-Host "`nChecking and repairing system registry..."
reg scan
Write-Host "System registry checked and repaired." -ForegroundColor Green
# Step 8: Fixing corrupted user profile (Optional)
$fixUserProfileChoice = Read-Host "`nDo you want to attempt fixing a corrupted user profile? (Y/N)"
if ($fixUserProfileChoice -match "[Yy]") {
Write-Host "Creating a new user profile..."
New-LocalUser "NewUser" -Password (ConvertTo-SecureString "password" -AsPlainText -Force)
Add-LocalGroupMember -Group "Administrators" -Member "NewUser"
Write-Host "A new user profile has been created. You may want to transfer data from the old profile." -ForegroundColor Yellow
}
# Final Question: Restart the computer
$restartFinalChoice = Read-Host "`nDo you want to restart the computer now? (Y/N)"
if ($restartFinalChoice -match "[Yy]") {
Write-Host "Restarting the computer..." -ForegroundColor Yellow
Restart-Computer -Force
} else {
Write-Host "System check and repair process completed. Please restart the computer manually if needed." -ForegroundColor Cyan
}
Последнее редактирование: