Why did my Windows PC restart? One command, instant answers.
Project description
wtf-restarted
WhyTF did my Windows PC restart? One command, instant answers.
The Problem
Your Windows PC restarted and you don't know why. Maybe you were away. Maybe it happened overnight. You come back to a fresh desktop and zero context. The "official" answer is to open Event Viewer, navigate through layers of cryptic logs, and decode event IDs. Most users never do this.
wtf-restarted reads the same event logs, crash dumps, and system state that Event Viewer uses, but gives you a plain-language verdict instead of raw event XML.
Quick Start
pip install wtf-restarted
wtf-restarted
That's it. You'll see something like:
Static screenshot if the GIF doesn't load
What It Checks
WTF-restarted (pronounced: wut-thuh-eff re-tar-ded) reads the same Windows Event Logs that Event Viewer uses, but focuses on the events that actually matter for answering "why did my PC restart?"
It starts by looking for signs of a dirty shutdown. For example, Windows records kernel-level markers like Event 41 and 6008, which are indicators the system didn't shut down cleanly. This catches power losses, hard resets, and BSODs.
Next, wtfr checks whether a process requested the restart (Event 1074). This is how Windows tracks which program (usually Windows Update, but sometimes a user or an installer) asked the system to reboot. If a restart was requested and the shutdown was clean, the answer is straightforward.
For crashes, the tool looks for BugCheck reports from Windows Error Reporting, crash dump files on disk (MEMORY.DMP, minidumps), and WHEA hardware errors that point to CPU, memory, or PCIe faults. If kd.exe (the Windows SDK debugger) is installed, it can crack open the dump file and extract the exact bugcheck code and faulting driver.
It also collects supporting context: Windows Update activity near the restart time, application crashes in the hour before reboot, GPU driver timeouts (TDR events), power state transitions (sleep/wake/hibernate), and the boot/shutdown sequence to distinguish clean restarts from dirty ones. If you're connected via Remote Desktop, it warns you that your "missing windows" might just be on a different session.
For the full list of event IDs, providers, manual lookup steps, and how to add your own checks, see docs/event-reference.md.
Commands
# Why did my PC restart? (default command)
wtf-restarted #Or the short alias: wtfr
# Show restart history (last 30 days)
wtf-restarted history
wtf-restarted history --days 90
# Look further back
wtf-restarted --hours 72
# Skip crash dump analysis (faster)
wtf-restarted --skip-dump
# Show more surrounding events for context
wtf-restarted --context-minutes 30
# Machine-readable JSON output
wtf-restarted --json
# Verbose mode (all event categories)
wtf-restarted -v
For detailed parameter descriptions, defaults, and guidance on when to adjust each flag, see docs/parameters.md.
Verdict Types
| Verdict | Color | Meaning |
|---|---|---|
| BSOD | Red | Blue Screen of Death -- crash dump found |
| UNEXPECTED SHUTDOWN | Yellow | Dirty shutdown, no initiator (power loss, hardware reset) |
| INITIATED RESTART | Cyan | A process requested the restart (often Windows Update) |
| MIXED SIGNALS | Magenta | Both dirty shutdown and restart initiator found |
| CLEAN RESTART | Green | Normal, expected restart |
Features
- Plain-language verdicts: No event IDs to decode -- just "Windows Update restarted your PC" or "BSOD caused by nvlddmkm.sys"
- Restart history: See patterns over time (is your PC crashing every week?)
- Surrounding events: Shows what happened in the minutes before a restart for context
- RDP awareness: Warns if you're in a Remote Desktop session and your "missing windows" might just be on a different session
- Crash dump analysis: If
kd.exe(Windows SDK Debugger) is installed, extracts bugcheck code, faulting module, and failure bucket from crash dumps - JSON output: Pipe to
jq, save to file, or feed to AI tools for deeper analysis - Zero mandatory dependencies: Core analysis uses only PowerShell (built into Windows). The Python CLI adds Rich for pretty output.
Using the PowerShell Scripts Directly
The investigation engine is a standalone PowerShell script that works without Python. If you prefer PowerShell or want to integrate restart diagnosis into your own scripts:
# Run the investigation directly
powershell -File investigate.ps1
# Get JSON output for scripting
powershell -File investigate.ps1 -JsonOnly | ConvertFrom-Json
# Look back further, skip dump analysis
powershell -File investigate.ps1 -LookbackHours 72 -SkipDump
See docs/powershell-engine.md for the full parameter reference, JSON schema, dot-sourcing for interactive use, and integration examples.
Requirements
- Windows 10 or 11 (PowerShell 5.1+)
- Python 3.10+
- Administrator recommended (some event logs require elevation)
- kd.exe optional (for crash dump analysis -- part of Windows SDK Debugging Tools)
Installation
# From PyPI
pip install wtf-restarted
# From source
git clone https://github.com/djdarcy/wtf-restarted.git
cd wtf-restarted
pip install -e ".[dev]"
Roadmap
- AI-enhanced diagnosis (Claude Code, Codex integration)
- Auto-install helper for kd.exe / Windows SDK
- Cross-platform support (Linux, macOS)
- mcp-windbg integration for structured dump analysis
See ROADMAP.md for the full phased plan, or track progress on issue #3.
Related Projects
- Stop-Windows-Restarting -- Prevent Windows Update from forcing reboots (complementary: diagnose vs prevent)
- mcp-windbg -- MCP server for WinDbg (future integration target)
Contributing
Contributions welcome! See CONTRIBUTING.md.
Like the project?
License
wtf-restarted, Copyright (C) 2026 Dustin Darcy
This project is dual-licensed:
- Open source: GNU Affero General Public License v3.0 (AGPL-3.0) -- see LICENSE
- Commercial: Contact djdarcy for commercial licensing if AGPL terms don't fit your use case
The AGPL is identical to GPL v3, with one addition: if you run a modified version of this software as a network service, you must make your source code available to users of that service. This ensures improvements to the diagnostic engine benefit everyone. Individual and self-hosted use is unaffected.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wtf_restarted-0.1.1.tar.gz.
File metadata
- Download URL: wtf_restarted-0.1.1.tar.gz
- Upload date:
- Size: 38.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a008b824015adb21f2c801948df196f150766526f2c0190a1de8df516224d5a
|
|
| MD5 |
dd1d1daf249dc295121e02e891d901c3
|
|
| BLAKE2b-256 |
f8070e593587e31bf469da9bb15462b8c190c0e5e685f512034f275b019b59fb
|
Provenance
The following attestation bundles were made for wtf_restarted-0.1.1.tar.gz:
Publisher:
release.yml on djdarcy/wtf-restarted
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wtf_restarted-0.1.1.tar.gz -
Subject digest:
7a008b824015adb21f2c801948df196f150766526f2c0190a1de8df516224d5a - Sigstore transparency entry: 1090467073
- Sigstore integration time:
-
Permalink:
djdarcy/wtf-restarted@91d19cfb45d81c2cd7bee9cd263d070764992659 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/djdarcy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d19cfb45d81c2cd7bee9cd263d070764992659 -
Trigger Event:
push
-
Statement type:
File details
Details for the file wtf_restarted-0.1.1-py3-none-any.whl.
File metadata
- Download URL: wtf_restarted-0.1.1-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b033924abd46f74f26d1191b791e87227e866ad2f2a173de379d936722c47f1a
|
|
| MD5 |
7248684dc32029dcb7258f5fa66e1b2a
|
|
| BLAKE2b-256 |
636d98d4ff11473fb7e19d735c761eaaca9f1ab8e9675032503528705c7ddb15
|
Provenance
The following attestation bundles were made for wtf_restarted-0.1.1-py3-none-any.whl:
Publisher:
release.yml on djdarcy/wtf-restarted
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wtf_restarted-0.1.1-py3-none-any.whl -
Subject digest:
b033924abd46f74f26d1191b791e87227e866ad2f2a173de379d936722c47f1a - Sigstore transparency entry: 1090467077
- Sigstore integration time:
-
Permalink:
djdarcy/wtf-restarted@91d19cfb45d81c2cd7bee9cd263d070764992659 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/djdarcy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d19cfb45d81c2cd7bee9cd263d070764992659 -
Trigger Event:
push
-
Statement type: