Originally published on 2009-02-05; fully revised and updated.
If you need quick, repeatable power actions on Windows hosts, a small .bat file is often enough. This article explains the original script style from the 2009 post, highlights important caveats, and gives modern command examples that work on current Windows systems.

What the original batch scripts are doing
The original post shows two commands: one for restart and one for shutdown, both calling a specific executable path instead of the built-in Windows command.
- Restart script path in the post:
D:\Temp\tmp\SHUTDOWN.EXE - Shutdown script path in the post:
d:\tmp\SHUTDOWN.EXE - Both scripts end with
pauseso the console stays open
Important: the paths are not identical in the source content. Confirm the executable location on your system before use.
Legacy SHUTDOWN.EXE vs built-in shutdown command
| Approach | Restart example | Shutdown example | When to use it | Notes |
|---|---|---|---|---|
| Legacy custom executable (as shown in original post) | D:\Temp\tmp\SHUTDOWN.EXE /L /R /Y /C | d:\tmp\SHUTDOWN.EXE /L /Y /C | Only when you must keep compatibility with an existing legacy script | Flag behavior depends on that specific binary/version |
| Built-in Windows command | shutdown /r /t 0 | shutdown /s /t 0 | Preferred for modern Windows automation | No custom executable path required |
Batch file examples
Legacy format preserved from the original post
Use this only if your environment still relies on that exact SHUTDOWN.EXE binary.
@echo off
D:\Temp\tmp\SHUTDOWN.EXE /L /R /Y /C
pauseCode language: CSS (css)
@echo off
d:\tmp\SHUTDOWN.EXE /L /Y /C
pauseCode language: CSS (css)
Modern Windows-friendly scripts
These examples use the built-in command available on current Windows systems.
@echo off
shutdown /r /t 0
pauseCode language: CSS (css)
@echo off
shutdown /s /t 0
pauseCode language: CSS (css)
Optional delayed shutdown with abort window:
shutdown /s /t 60
shutdown /a
Execution workflow
flowchart TD
A[Admin runs bat file] --> B{Use legacy SHUTDOWN EXE path}
B -- yes --> C[Run custom SHUTDOWN EXE with flags]
B -- no --> D[Run built in shutdown command]
C --> E{Command succeeds}
D --> E
E -- no --> F[Check path permissions or flags]
E -- yes --> G[System restarts or shuts down]
Common pitfalls and best practices
- Verify executable paths exactly; the original post shows two different directories.
- Prefer the built-in
shutdowncommand for new scripts to reduce dependency on legacy binaries. - Test first on a non-production machine to avoid accidental downtime.
- Use delayed shutdown (
/t) when users need a warning window before termination. - Document your script intent clearly (restart vs shutdown) in file names and comments.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals