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.

up vote 2 down vote accepted

Test this as a diagnostic step.

@echo off
"c:\Windows\System32\shutdown.exe" /s /t 20
pause

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.

Swap out our /s /t xx for -s -t xx. That fixed this on my Windows 10 system.

In PowerShell, you could use Stop-Computer.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.