A minimalist, interactive Windows Shutdown Timer, written entirely in pure Batch (.bat).
It lets you automatically power off your PC after a given number of hours โ with a live countdown and a system-wide timer that can be checked or canceled from any other Command Prompt window.
I originally wrote it so I could fall asleep to YouTube or podcasts without leaving my PC running all night. Windows hides its sleep options pretty well, so this script does the job instead.
- ๐ Custom timer (in whole hours)
- ๐งฎ Live console countdown (hh:mm:ss)
- ๐ง  Uses Windows' built-in shutdown /ttimer (globally visible)
- ๐ Real-time updates every second
- ๐งฐ Cancel anytime From another window;
shutdown /a
โน๏ธ The CTRL+C auto-cancel helper relies on Windows PowerShell. If PowerShell is unavailable, the script will warn you and CTRL+C falls back to the previous manual behavior.
- Download sleep.bator copy the code into a new.batfile.
- Double-click the file to launch it.
- Enter how many hours you want your PC to stay on (whole numbers only).
Example prompt:
How many hours from now should the PC shut down? (e.g. 1, 2, 5): 3
The window displays a live countdown like this:
Shutdown Countdown
Remaining Time: 02:59:45   (hh:mm:ss)
Cancel: CTRL+C  or from another window: shutdown /a
The script targets Windows' Command Prompt. To verify it manually:
- Open cmd.exeon a Windows machine.
- Run sleep.bat(double-clicking works too).
- Provide a small value such as 1to confirm the countdown and the systemshutdown /ttimer are set.
- Press CTRL+Cto verify the script automatically issuesshutdown /a(you can still cancel from another window withshutdown /a).
Automated testing is not available for Batch files in this repository, and the script cannot be executed on non-Windows environments such as this Linux container.
You can check or cancel the active shutdown timer anytime in another Command Prompt window:
shutdown /a- If a timer was active โ itโs canceled.
- If no timer was running โ youโll see this message:
The system shutdown cannot be aborted because no shutdown is in progress. (1116)
Enjoy the rest โ your PC will turn itself off when the countdown ends. ๐ด