How to create batch file to shutdown computer?

Click For Summary
SUMMARY

This discussion focuses on creating a batch file for shutting down a computer using the command line. The user, Nate Duong, encountered issues where the batch file did not execute the shutdown command properly. The solution involves renaming the batch file to avoid conflicts with the system's shutdown.exe or providing the full path to the executable. Additionally, using the command "shutdown /s /f /t 0" allows for an immediate and forced shutdown without user prompts.

PREREQUISITES
  • Basic understanding of batch file creation in Windows
  • Familiarity with command line operations
  • Knowledge of the shutdown command syntax
  • Experience with file path management in Windows
NEXT STEPS
  • Research how to create and execute batch files in Windows
  • Learn about the various parameters of the shutdown command
  • Explore troubleshooting techniques for batch file execution issues
  • Investigate the use of other command line utilities for system management
USEFUL FOR

This discussion is beneficial for Windows users, system administrators, and anyone interested in automating shutdown processes through batch files.

Nate Duong
Messages
125
Reaction score
4
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,

Nate Duong.
 

Attachments

  • IMG_2487.JPG
    IMG_2487.JPG
    41 KB · Views: 525
Technology news on Phys.org
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   Reactions: mfb
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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
Replies
10
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
2K
Replies
7
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K