How to create batch file to shutdown computer?

  • Thread starter Nate Duong
  • Start date
  • #1
126
3
Dear Group,

I would like to ask a question regarding to the batch file,

I am trying to create a batch file which could help to to shutdown to computer quickly, but when i run batch file, the command window showed up and keep running too many line but did not shut down the computer.

But when I typed directly on the command line window, it worked.

Please give me an advise, and this is a simple code and picture of the problem.
@Echo off
shutdown /s

Thank you group,
Best regards,
Nate Duong.
 

Attachments

Answers and Replies

  • #2
Filip Larsen
Gold Member
1,329
243
If you name your batch file "shutdown.bat" (or "shutdown.cmd") and invoke it from its own directory (that is, the current working directory where the batch file is placed), then the batch file is not calling the windows shutdown.exe but your own batch file instead. If this is the case, then try rename your batch file to something else, or alternatively, provide a full path to the shutdown.exe.
 
  • Like
Likes mfb
  • #3
FactChecker
Science Advisor
Gold Member
5,976
2,296
The default wait time before the shutdown starts is 30 seconds. To make it start immediately, use /t 0. To make it force a shutdown without warning the user, use /f. So try "shutdown /s /f /t 0"

You can see all the details by typing shutdown /? in a DOS command window.
 

Related Threads on How to create batch file to shutdown computer?

Replies
4
Views
3K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
11
Views
588
  • Last Post
2
Replies
33
Views
653
Replies
5
Views
812
Replies
5
Views
2K
Replies
3
Views
830
Replies
15
Views
1K
Replies
3
Views
2K
Top