Solved shutdown /r in a batch script


shoober420

Well-known member
Member
VIP
Local time
11:29 AM
Posts
231
OS
Windows 11 27965
when i put
Code:
shutdown /r
in a batch script, it spams the command in the terminal when opened but doesnt reboot the machine. why does this command behave this way in a batch script?
 
Windows Build/Version
Windows 11 27954

My Computer

System One

  • OS
    Windows 11 27965
    Computer type
    PC/Desktop
    CPU
    Intel i7 7700 @4.0ghz
    Memory
    64gb DDR4
    Graphics Card(s)
    Radeon RX 5500 XT
    Sound Card
    Topping D50s
    Hard Drives
    NVMe
    PSU
    Corsair
    Keyboard
    Stelseries G6v2
    Mouse
    Zowie EC2
    Other Info
    https://www.youtube.com/shoober420
I agree with garlin.

My own shutdown is a shortcut rather than a batch file but works in the same way:-
shutdown.exe /r /t 0 /f /c "Restart in Menus"

There's guidance in Shutdown - SS64

I use the /c switch so that I can see my deliberate shutdowns in Event viewer.
It doesn't make very much difference but I think I'll appreciate knowing which entries were deliberate if I ever have to investigate shutdown-related problems.
[Log - System, Source - User32, EventID 1074]
Shutdown comment.webp



All the best,
Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 25H2 Build 26200.8037
i had to add .exe at the end of shutdown for the batch script to launch properly (shutdown.exe /s)
 

My Computer

System One

  • OS
    Windows 11 27965
    Computer type
    PC/Desktop
    CPU
    Intel i7 7700 @4.0ghz
    Memory
    64gb DDR4
    Graphics Card(s)
    Radeon RX 5500 XT
    Sound Card
    Topping D50s
    Hard Drives
    NVMe
    PSU
    Corsair
    Keyboard
    Stelseries G6v2
    Mouse
    Zowie EC2
    Other Info
    https://www.youtube.com/shoober420
i had to add .exe at the end of shutdown for the batch script to launch properly (shutdown.exe /s)
I've seen that before.

Please run this in a cmd window
echo %pathext%
or this in a PS window
Get-ChildItem Env:pathext
You should get the response
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC


Denis
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Home x64 Version 25H2 Build 26200.8037
Back
Top Bottom