Reputation: 89
As the title says, the typical shutdown /s /t xx
command doesn't work when I run it from a script. Instead of shutting down after x
seconds, it only runs the shutdown
part, and ignores the arguments. However, if I type it manually in a Command Prompt window, it executes correctly. I tried running other commands from a script like ipconfig /all
and I have no problems. Is this a general Windows 10 problem or did I mess up with something on my computer?
P.S. I get the same results with Powershell as well.
Upvotes: 1
Views: 23273
Reputation: 1
Open notepad
Type in
shutdown /s /t 00
Save as shutdown.cmd to your desktop
Double click and this should work.
Upvotes: 0
Reputation: 2448
Might be worth mentioning Powershell doesn't always play nice with external executables and command line switches/arguments. Try using:
Start-Process shutdown.exe -ArgumentList "/s /t 20"
Also, there is Invoke-Item
which can start a process but I've noticed using Start-Process
Reference this for more information.
Upvotes: 1
Reputation: 41244
Test this as a diagnostic step.
@echo off
"c:\Windows\System32\shutdown.exe" /s /t 20
pause
Upvotes: 9
Reputation: 2362
Swap out our /s /t xx
for -s -t xx
. That fixed this on my Windows 10 system.
Upvotes: 3