1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Shutdown -s -m Batch File

Discussion in 'Networking' started by callumgoldin, Jan 23, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. callumgoldin

    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.
     
  2. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,418
    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.
     
  3. callumgoldin

    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.
     
  4. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,418
    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.
     
  5. Frank4d

    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.
     
  6. callumgoldin

    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.
     
  7. Bob Cerelli

    Bob Cerelli

    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
     
  8. callumgoldin

    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.
     
  9. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,418
    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
     
  10. Bob Cerelli

    Bob Cerelli

    Joined:
    Nov 2, 2002
    Messages:
    22,468
    So is the problem with something for a pause not working or with the shutdown repeating or not closing. Two very different problems.
     
  11. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,418
    BTW, SLEEP has to be on your path or have a complete path specification to it.
     
  12. callumgoldin

    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,
     
  13. Bob Cerelli

    Bob Cerelli

    Joined:
    Nov 2, 2002
    Messages:
    22,468
  14. callumgoldin

    callumgoldin Thread Starter

    Joined:
    Mar 7, 2006
    Messages:
    66
    Much obliged
     
  15. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
  16. Sponsor

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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/537691

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice