mirror of
https://github.com/ZenDeuo/WinRepair.git
synced 2026-06-22 01:40:59 +01:00
v1.0.0 - WinRepair Utility
Initial upload of WinRepair in its current working, fully featured state! + Includes Debugging Scripts.
This commit is contained in:
parent
34dbb7f4f2
commit
2174584dfa
2 changed files with 136 additions and 0 deletions
28
Run WinRepair_Debug.bat
Normal file
28
Run WinRepair_Debug.bat
Normal 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
|
||||||
108
WinRepair_Debug.ps1
Normal file
108
WinRepair_Debug.ps1
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
<#
|
||||||
|
.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
|
||||||
|
} 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) {
|
||||||
|
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")
|
||||||
Loading…
Add table
Reference in a new issue