Shutdown -s -m Batch File

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

callumgoldin

Thread Starter
Joined
Mar 7, 2006
Messages
66
Hello there,

I'm trying to setup a batch file as follows; -

shutdown -s -m \\PC-Name01
shutdown -s -m \\PC-Name02
shutdown -s -m \\PC-Name03
shutdown -s -m \\PC-Name04
etc

When this runs the first line seems to get into a loop and keeps repeating itself and will not move on to the next line, it also does not shutdown \\PC-Name01

When "shutdown -s -m \\PC-Name01" is run as an individual command it works fine.
 

JohnWill

Retired Moderator
Joined
Oct 19, 2002
Messages
106,425
Try:

start shutdown -s -m \\PC-Name01
start shutdown -s -m \\PC-Name02
start shutdown -s -m \\PC-Name03
start shutdown -s -m \\PC-Name04
etc.
 

callumgoldin

Thread Starter
Joined
Mar 7, 2006
Messages
66
Hi

I ran into some trouble with that. Instead of one window becoming flooded it opens up multiple command prompt windows, eventually I had to shutdown my PC. Please note I'm running Vista, but I can't see how this would affect a batch file.
 

JohnWill

Retired Moderator
Joined
Oct 19, 2002
Messages
106,425
Hmm... It works here, but note that it takes a few seconds for the shutdown command to finish, which is probably why it's creating so many windows. Let's try plan B, inserting a 10 second delay between each shutdown command so as not to swamp the system.

start shutdown -s -m \\PC-Name01
REM - insert 10 second delay
TYPE NUL | CHOICE.COM /N /CY /TY,10 >NUL
start shutdown -s -m \\PC-Name02
REM - insert 10 second delay
TYPE NUL | CHOICE.COM /N /CY /TY,10 >NUL
start shutdown -s -m \\PC-Name03
REM - insert 10 second delay
TYPE NUL | CHOICE.COM /N /CY /TY,10 >NUL
start shutdown -s -m \\PC-Name04
REM - insert 10 second delay
TYPE NUL | CHOICE.COM /N /CY /TY,10 >NUL
etc.
 

Frank4d

Retired Trusted Advisor
Joined
Sep 10, 2006
Messages
9,126
If choice.com is not available in your version of Windows,
PING 1.1.1.1 -n 1 -w 10000 >NUL will also delay 10 seconds.
 

callumgoldin

Thread Starter
Joined
Mar 7, 2006
Messages
66
Sorry I'm not in the know when it comes to MsDOS. Can you explain a little more what these lines do & what needs editing; -
REM - insert 10 second delay
TYPE NUL | CHOICE.COM /N /CY /TY,10 >NUL

Thank you.
 
Joined
Nov 2, 2002
Messages
22,468
I don't think the "choice" program is on all computers. The ping wait didn't wait anywhere near 10 seconds for me. Since the 10 second thing isn't exact, just a general pause, you could change it to ping 127.0.0.1 -n 10
 

callumgoldin

Thread Starter
Joined
Mar 7, 2006
Messages
66
I've just tried; -

shutdown -s -m \\F11compaq
ping 127.0.0.1 -n 10
shutdown -s -m \\F11compaq

This did exactly the same thing where shutdown -s -m \\F11compaq just repeats itself infinitely until you either exit or CTRL+C.

If I try; -

start shutdown -s -m \\F11compaq
ping 127.0.0.1 -n 10
start shutdown -s -m \\F11compaq

things get even worse and window upon window of cmd's open with no other option but to switch off.
 

JohnWill

Retired Moderator
Joined
Oct 19, 2002
Messages
106,425
Wait one...

I need to remove my foot from my mouth! :eek:

Apparently, I have some of the W98 commands in my utilities folder, CHOICE.COM being one of them. That's why my batch job works here.

Here's SLEEP, a small utility to insert the delay, put it on your path and change the CHOICE lines to:

SLEEP 10
 
Joined
Nov 2, 2002
Messages
22,468
callumgoldin said:
I've just tried; -

shutdown -s -m \\F11compaq
ping 127.0.0.1 -n 10
shutdown -s -m \\F11compaq

This did exactly the same thing where shutdown -s -m \\F11compaq just repeats itself infinitely until you either exit or CTRL+C.

If I try; -

start shutdown -s -m \\F11compaq
ping 127.0.0.1 -n 10
start shutdown -s -m \\F11compaq

things get even worse and window upon window of cmd's open with no other option but to switch off.
So is the problem with something for a pause not working or with the shutdown repeating or not closing. Two very different problems.
 

JohnWill

Retired Moderator
Joined
Oct 19, 2002
Messages
106,425
BTW, SLEEP has to be on your path or have a complete path specification to it.
 

callumgoldin

Thread Starter
Joined
Mar 7, 2006
Messages
66
Hi Guys,

No the problem was that there was no pause or it just didn't know how to get to the next line. I finally found a solution. Thanks John for the Sleep though, that works too.

Here's the batch file that works,

for /f %%u in (PCs.txt) do (
start shutdown.exe -s -m \\%%u -f -t 60 -d 0:0 -c "daily shutdown"
)

I then created a txt file named "PCs" (call it what you want as long as it matches in your batch file) containing a list of all PC's I wanted to shutdown and saved both batch file and txt file in one of my PATHS.

Voila,
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

No members online now.
Top