+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
Scripts Thread, Script to shutdown computers. in Coding and Web Development; hi I am looking a script that will shutdown a small selection of computers. I would prefer it if the ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,037
    Thank Post
    888
    Thanked 1,725 Times in 1,490 Posts
    Blog Entries
    12
    Rep Power
    453

    Script to shutdown computers.

    hi

    I am looking a script that will shutdown a small selection of computers. I would prefer it if the script looked at a text file to define the computers rather having the computer names in the script.

    Does anyone have one please?

    Z

  2. #2

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,223
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    Try this one does it by text file or OU and logs any errors:
    Redmond | Column: Shut Down, Already
    Last edited by SYNACK; 21st June 2008 at 10:14 PM.

  3. #3
    Lesley_tech's Avatar
    Join Date
    May 2008
    Posts
    40
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    13
    Run -> CMD -> shutdown -i -> Browse -> find computers -> Add note -> shutdown

    Hope this helps

  4. #4

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,037
    Thank Post
    888
    Thanked 1,725 Times in 1,490 Posts
    Blog Entries
    12
    Rep Power
    453
    Quote Originally Posted by Lesley_tech View Post
    Run -> CMD -> shutdown -i -> Browse -> find computers -> Add note -> shutdown

    Hope this helps
    I use that utility allot but its not quite what i am after.

    Quote Originally Posted by SYNACK View Post
    Try this one does it by text file or OU and logs any errors:
    Redmond | Column: Shut Down, Already
    Would i just list the computers in the .txt one on each line?

    also for shutting them down would i use
    Code:
    /action:poweroff
    Last edited by FN-GM; 21st June 2008 at 10:39 PM.

  5. #5

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,223
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    Quote Originally Posted by FN-Greatermanchester View Post
    Would i just list the computers in the .txt one on each line?

    also for shutting them down would i use
    Code:
    /action:poweroff
    Yes sounds right, haven't actually used it before but the standard method is a pc name on each line and you would want to use the command switch above to make them fully shutdown.

  6. #6

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,037
    Thank Post
    888
    Thanked 1,725 Times in 1,490 Posts
    Blog Entries
    12
    Rep Power
    453
    you can no longer download the tool!

  7. #7

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,223
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    Here is is as a code listing, you will need to copy it and paste it into a text file called shutdownrestart.wsf
    Best Practice 97 - Shutdown Shutdownrestart.wsf

  8. #8

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    PSshutdown - [ Part of the Admin Bar ]

  9. #9

    Join Date
    May 2008
    Location
    York
    Posts
    515
    Thank Post
    22
    Thanked 49 Times in 46 Posts
    Rep Power
    24

    shutdown

    we use psshutdown its one of the best tools we have found see below

    PsShutdown from sysinternals (Now part of Microsoft)

    download from
    PsShutdown
    Initiate a shutdown/reboot of a local or remote computer, logoff a user, lock a system.

    Syntax
    psshutdown [[\\computer[,computer[,..] | @file [-u user [-p passwd]]]
    -s|-r|-h|-d|-k|-a|-l|-o
    [-f] [-c] [-t nn|h:m] [-n s] [-v nn]
    [-e [u|p]:xx:yy] [-m "message"]
    Options:

    computer The computer on which the user account resides. Default=local system
    a wildcard (\\*), will affect all computers in the current domain.

    -p passwd Specify a password for user (optional). Passed as clear text.
    If omitted, you will be prompted to enter a hidden password.

    -u user Specify a user name for login to remote computer(optional).

    @file Execute the command on each of the computers listed in the file.

    -a Abort a shutdown (only possible while a countdown is in progress)

    -c Allow the shutdown to be aborted by the interactive user

    -d Suspend the computer

    -e [u|p]:xx:yy
    Shutdown reason code, 'u' = user, 'p'= planned shutdown.
    xx is the major reason code (must be less than 256)
    yy is the minor reason code (must be less than 65536)

    -f Force all running applications to exit during the shutdown
    instead of giving them a chance to gracefully save their data.

    -h Hibernate the computer

    -k Poweroff the computer (reboot if poweroff is not supported)

    -l Lock the computer

    -m "message" Specify a message to logged-on users when a shutdown countdown commences

    -n Timeout in seconds connecting to remote computers

    -o Logoff the console user

    -r Reboot after shutdown

    -s Shutdown without poweroff

    -t Countdown in seconds until the shutdown (default: 20 seconds)
    or the time of shutdown (in 24 hour notation)

    -v Display message for the specified number of seconds before the shutdown.
    default= display a shutdown notification dialog,
    specifying a value of 0 results in no dialog.

    - Help, display the supported options.
    This tool allows administrators to create a batch file that will run against multiple computers to perform a mass change of the administrator password.

    Examples:

    Reboot \\workstation64 as part of an OS upgrade

    psshutdown \\workstation64 -r -e p:2:3

    Related Commands:

    SHUTDOWN - With full list of reason codes

    Equivalent Linux BASH command:

    shutdown - Shutdown or restart linux

  10. #10

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,527
    Thank Post
    1,339
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    199
    Code:
    @echo off
    cls
    echo Shutting Down Computers...
    
    if not exist computers.txt goto NOTFOUND
    FOR /F %%i in (computers.txt) do shutdown -s -m \\%%i
    goto END
    
    :NOTFOUND
    echo computers.txt not found
    GOTO END
    
    
    :END
    echo Done...
    just put all the computer names in computer.txt

  11. Thanks to RabbieBurns from:

    tosh74 (26th June 2008)

  12. #11

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    I miss GOTO commands.....
    I hated having to port some of my older batch type stuff into loops......

    Still, thats life.

  13. #12

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    @Zak: PM me, I have a home-made tool I'd like you to beta if that's ok.

  14. #13

    SpuffMonkey's Avatar
    Join Date
    Jul 2005
    Posts
    2,240
    Thank Post
    55
    Thanked 278 Times in 186 Posts
    Rep Power
    134
    Could someone post a script to shutdown PCs using psshutdown? It keeps hanging when I try it - I try to give a warning, then shutdown and log it all to a log file (2003 & XP)

  15. #14

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    Quote Originally Posted by SpuffMonkey View Post
    Could someone post a script to shutdown PCs using psshutdown? It keeps hanging when I try it - I try to give a warning, then shutdown and log it all to a log file (2003 & XP)
    This is what the Admin Bar does:

    psshutdown -c -k @shutdownpcs.txt -f -t 30

  16. #15

    SpuffMonkey's Avatar
    Join Date
    Jul 2005
    Posts
    2,240
    Thank Post
    55
    Thanked 278 Times in 186 Posts
    Rep Power
    134
    Quote Originally Posted by mattx View Post
    This is what the Admin Bar does:

    psshutdown -c -k @shutdownpcs.txt -f -t 30
    Thanks - I'll give it a try.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Script to add computers to AD like RIS
    By box_l in forum Scripts
    Replies: 2
    Last Post: 4th June 2008, 08:34 PM
  2. Shutdown batch script stalls if 1 PC is shut down
    By PrimaryTech in forum Scripts
    Replies: 8
    Last Post: 7th July 2007, 06:04 PM
  3. Replies: 3
    Last Post: 23rd March 2007, 09:36 AM
  4. VBS script for prestaging computers anyone?
    By ChrisH in forum Scripts
    Replies: 7
    Last Post: 23rd June 2006, 09:59 AM
  5. Replies: 18
    Last Post: 14th October 2005, 09:28 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •