How to create batch file to shutdown computer?

AI Thread Summary
To create a batch file that effectively shuts down a computer, ensure the file is named differently from the system's shutdown command to avoid conflicts. The command should be structured as "shutdown /s /f /t 0" for an immediate and forced shutdown without warnings. If the batch file is not executing properly, check that it is invoked from its own directory. Users can view additional shutdown options by typing "shutdown /?" in a command window. Following these guidelines should resolve the issue of the batch file not functioning as intended.
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: 499
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 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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Back
Top