Compare commits

..

2 commits

Author SHA1 Message Date
Ryan
53d18ecea2 v1.0.1!
- Due to friend suffering issues with the SFC command, added a watchdog to detect if a command hangs for >45s and pops up a Window asking the user if they'd like to retry the command, skip the command or just outright cancel the command.
- Moved Smark Disk Check and moved it to its own section with better output about your disk's help.
- Fixed an issue with the Debug Console where it used to say the program had crashed when actually it was just the user that closed the window.
- Improved the debug consoles logging capabilities.
2026-02-19 16:39:03 +00:00
Ryan
2174584dfa v1.0.0 - WinRepair Utility
Initial upload of WinRepair in its current working, fully featured state!
+ Includes Debugging Scripts.
2026-02-17 05:34:01 +00:00
2 changed files with 139 additions and 0 deletions

28
Run WinRepair_Debug.bat Normal file
View file

@ -0,0 +1,28 @@
@echo off
title WinRepair - DEBUG MODE
:: ═══════════════════════════════════════════════════════════════
:: WinRepair Debug Launcher
:: Runs WinRepair with a VISIBLE console for error tracking
:: Debug log saved to WinRepair_Debug.log
:: ═══════════════════════════════════════════════════════════════
:: Check for admin rights
net session >nul 2>&1
if %errorlevel% neq 0 (
echo Requesting Administrator privileges...
powershell -NoProfile -Command "Start-Process cmd.exe -ArgumentList '/c \"\"%~f0\"\"' -Verb RunAs"
exit /b
)
:: We are admin — change to script directory and run with visible console
pushd "%~dp0"
chcp 65001 >nul
echo ============================================
echo WinRepair DEBUG MODE
echo Console output + WinRepair_Debug.log
echo ============================================
echo.
powershell.exe -NoProfile -NoExit -ExecutionPolicy Bypass -File ".\WinRepair_Debug.ps1"
popd

111
WinRepair_Debug.ps1 Normal file
View file

@ -0,0 +1,111 @@
<#
.SYNOPSIS
WinRepair Debug Launcher
.DESCRIPTION
Runs WinRepair.ps1 as a CHILD PROCESS with full transcript logging,
visible console, and crash detection. The debug console stays open
even if WinRepair crashes or calls exit.
Debug log is saved to WinRepair_Debug.log in the same directory.
.NOTES
Run this via RunRepair_Debug.bat when troubleshooting issues.
The console window WILL remain open even after a crash.
#>
# ==============================================================================
# DEBUG SETUP
# ==============================================================================
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$debugLog = Join-Path $scriptDir "WinRepair_Debug.log"
$errorLog = Join-Path $scriptDir "WinRepair_Error.log"
$mainScript = Join-Path $scriptDir "WinRepair.ps1"
# Clear previous logs
"" | Out-File -FilePath $debugLog -Force
if (Test-Path $errorLog) { Remove-Item $errorLog -Force }
Write-Host "==========================================================" -ForegroundColor Cyan
Write-Host "|| WinRepair - DEBUG MODE ||" -ForegroundColor Cyan
Write-Host "|| Logging to: WinRepair_Debug.log ||" -ForegroundColor Cyan
Write-Host "|| This window stays open after crashes ||" -ForegroundColor Cyan
Write-Host "==========================================================" -ForegroundColor Cyan
Write-Host ""
# Start transcript
Start-Transcript -Path $debugLog -Append | Out-Null
Write-Host "[DEBUG] Script directory: $scriptDir" -ForegroundColor Yellow
Write-Host "[DEBUG] Main script: $mainScript" -ForegroundColor Yellow
Write-Host "[DEBUG] PowerShell version: $($PSVersionTable.PSVersion)" -ForegroundColor Yellow
Write-Host "[DEBUG] OS: $([System.Environment]::OSVersion.VersionString)" -ForegroundColor Yellow
Write-Host "[DEBUG] Running as Admin: $(([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))" -ForegroundColor Yellow
Write-Host "[DEBUG] Date: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -ForegroundColor Yellow
Write-Host ""
# ==============================================================================
# LAUNCH WINREPAIR AS A CHILD PROCESS
# This is the key difference: Start-Process creates a SEPARATE process,
# so even if WinRepair calls "exit 1", only the child dies.
# This debug console survives no matter what.
# ==============================================================================
Write-Host "[DEBUG] Launching WinRepair.ps1 as child process..." -ForegroundColor Green
Write-Host "[DEBUG] -----------------------------------------------" -ForegroundColor DarkGray
Write-Host ""
$startTime = Get-Date
# Set env var so WinRepair.ps1 skips hiding the console window
$env:WINREPAIR_DEBUG = "1"
$childProc = Start-Process -FilePath "powershell.exe" `
-ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$mainScript`" -DebugMode" `
-PassThru -NoNewWindow
# Wait for the child process to finish
$childProc.WaitForExit()
$exitCode = $childProc.ExitCode
$elapsed = (Get-Date) - $startTime
Write-Host ""
Write-Host "[DEBUG] -----------------------------------------------" -ForegroundColor DarkGray
if ($exitCode -eq 0) {
Write-Host "[DEBUG] WinRepair exited normally (code 0)" -ForegroundColor Green
} elseif ($null -eq $exitCode) {
Write-Host "[DEBUG] WinRepair closed manually (Exit Code: NULL)" -ForegroundColor Yellow
} else {
Write-Host "[DEBUG] WinRepair CRASHED with exit code: $exitCode" -ForegroundColor Red
}
Write-Host "[DEBUG] Duration: $($elapsed.ToString('mm\:ss'))" -ForegroundColor Yellow
# Check for error log from WinRepair's trap handler
if (Test-Path $errorLog) {
$errorContent = Get-Content $errorLog -Raw
if ($errorContent -and $errorContent.Trim() -ne "") {
Write-Host ""
Write-Host "==========================================================" -ForegroundColor Red
Write-Host " CRASH DETAILS (from WinRepair_Error.log) " -ForegroundColor Red
Write-Host "==========================================================" -ForegroundColor Red
Write-Host ""
Write-Host $errorContent -ForegroundColor Yellow
Write-Host ""
Write-Host "==========================================================" -ForegroundColor Red
}
} else {
if ($exitCode -ne 0 -and $null -ne $exitCode) {
Write-Host ""
Write-Host "[DEBUG] No WinRepair_Error.log found. The crash may have" -ForegroundColor Red
Write-Host "[DEBUG] bypassed the error handler (e.g. .NET exception)." -ForegroundColor Red
}
}
Write-Host ""
Write-Host "[DEBUG] Full debug log saved to: $debugLog" -ForegroundColor Yellow
Stop-Transcript -ErrorAction SilentlyContinue | Out-Null
Write-Host ""
Write-Host "Press any key to close this window..." -ForegroundColor Cyan
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Stop-Process -Id $PID