Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a hibernation batch file?

I'm trying to make a batch file that executes a simple command:

shutdown -h

I've created a shutdown.bat file with that exact line in it, yet when I run it, all it does is spam the command prompt like crazy.

I've looked at batch file sites, @echo off seems popular, but doesn't that just hide output while the commands are executed just the same?

like image 462
ryanscottmurphy Avatar asked Jan 19 '23 09:01

ryanscottmurphy


2 Answers

It turns out that adding a change directory command to the root of the drive fixes the problem. The final text that I ended up using in the .bat file was:

cd c:\
shutdown /h
like image 154
ryanscottmurphy Avatar answered Feb 01 '23 23:02

ryanscottmurphy


I believe I am very late for this but just in case someone else comes across this. The issue was indeed with the name of the bat file. You were calling shutdown -h and the bat file was called shutdown.bat hence the bat file was calling itself causing the loop of the command prompts. To fix this you either rename the bat file or specify the directory where shutdown is located.

like image 37
LJ Neveral Avatar answered Feb 01 '23 23:02

LJ Neveral