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.

Solved: Shutdown DOS batch script

Discussion in 'Software Development' started by jp1203, Jul 5, 2007.

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

    jp1203 Thread Starter

    Joined:
    Jul 20, 2005
    Messages:
    3,427
    I have absolutely no idea where to put this, so I just picked a place. If anyone thinks there's a better spot for it, have it moved there please :D

    My intentions: to make a DOS batch script that will shut down four machines, then to set it as a scheduled task running at, say, 1 AM

    The Problem:
    I type something in DOS:

    shutdown -s -m \\computername -c "This machine will shut down in two minutes To cancel click the abort shutdown icon on your desktop" -t 120 -f

    It works, the remote machine displays a warning and a countdown timer. I have an icon on their desktop that is a batch script with contents:

    shutdown -a

    to abort the shutdown if someone is on the machine at 1 AM.


    If I copy the same script (the shut down one) into notepad save and run the batch file, it goes into this endless loop and does nothing. Anyone know why?

    I've attached a screenshot of the running batch script in its endless loop"
     

    Attached Files:

  2. dez_666

    dez_666

    Joined:
    May 29, 2007
    Messages:
    842
    Can you put the contents of your batch script in CODE tags please? Maybe i can help you out. (y)
     
  3. jp1203

    jp1203 Thread Starter

    Joined:
    Jul 20, 2005
    Messages:
    3,427
    Changed it slightly with some echo tags, that's all. Still obviously no go.

    Code:
    @echo off
    echo Starting Shutdown Process...
    echo Shutting Down Stergis2
    shutdown -s -m \\computername -c "This machine will shut down in two minutes To cancel click the abort shutdown icon on your desktop" -t 120 -f
    echo Script Complete.
    
     

    Attached Files:

  4. dez_666

    dez_666

    Joined:
    May 29, 2007
    Messages:
    842
    Ok let me ask this- Are you sure shutdown.exe is on your PC? and the remote pc? cos iytmay need it, and there might be a setting on the remote computer that allows it to be shut down remotely.
     
  5. jp1203

    jp1203 Thread Starter

    Joined:
    Jul 20, 2005
    Messages:
    3,427
    I imagine so, because if I just open cmd and type this it works fine and the other machine shows a message for two minutes and shuts down. It's just the script that won't work for some weird reason:

    shutdown -s -m \\computername -c "This machine will shut down in two minutes To cancel click the abort shutdown icon on your desktop" -t 120 -f
     
  6. dez_666

    dez_666

    Joined:
    May 29, 2007
    Messages:
    842
    :3 I have a neato idea. but first lemme ask you. would you be willing to use something other than shutdown.exe to shutdown other pc's?
     
  7. jp1203

    jp1203 Thread Starter

    Joined:
    Jul 20, 2005
    Messages:
    3,427
    So long as it isn't too bulky, probably.
     
  8. dez_666

    dez_666

    Joined:
    May 29, 2007
    Messages:
    842
    two things.

    PsShutdown from Sysinternals - Now owned by microsoft..

    http://www.microsoft.com/technet/sysinternals/Utilities/PsShutdown.mspx

    doesnt require anything installed on the client.

    but if you're a little adventurous, check this out.

    http://users.pandora.be/jbosman/applications.html

    you dont 'need' to install it on the remote pc, but if you dont you cant do any of the fancy things like standby and hibernate..or turning a monitor off.. xD
    but pwroff can do things by a scheduling them, and things can be done by command line, as well as remotely by command line. i wouldnt recommend it if you're looking for an easy solution, but its a fun program.
     
  9. jp1203

    jp1203 Thread Starter

    Joined:
    Jul 20, 2005
    Messages:
    3,427
    Cool, I'll have to try that Poweroff thing. I like to play :D

    Thanks Very Much
     
  10. dez_666

    dez_666

    Joined:
    May 29, 2007
    Messages:
    842
    you ought to check out the sysinternals suite in my sig. very useful tools in der. :)
    But dont get carried away, you can fry your PC with some of that stuff.
    but yea, tell me how poweroff goes, i love that thing xD
     
  11. jp1203

    jp1203 Thread Starter

    Joined:
    Jul 20, 2005
    Messages:
    3,427
    I use newsid from Sysinternals for mass imaging stuff so the SID and puter name are different for every box. Haven't really played with the rest of the stuff too much, I'll have to do that when I have some time to kill. I had a guy working with me who decided that NewSID locked up (it just hit a massive file to change) and rebooted the machine manually. Had to reimage it again.

    I scheduled poweroff to shut down a box at 1 AM with a 120 second warning, and started it as a service so we'll see what happens. I'll let you know.

    Thanks again
     
  12. jp1203

    jp1203 Thread Starter

    Joined:
    Jul 20, 2005
    Messages:
    3,427
    I like the looks of diskmon, as I run this box as a small server. I'll have to play with that.
     
  13. dez_666

    dez_666

    Joined:
    May 29, 2007
    Messages:
    842
    When you make a scheduled task in pwroff, dont forget to 'Save Setting To Service'. (y)
    And diskmon is for monitoring when your hard drive is read/written to. i find regmon more useful than that >_>'
     
  14. jp1203

    jp1203 Thread Starter

    Joined:
    Jul 20, 2005
    Messages:
    3,427
    Apparently the service ran, when I unlocked this this morning I had a poweroff message that the client accepted the task and that machine is off.

    Thanks
     
  15. 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!

Loading...
Thread Status:
Not open for further replies.

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