Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
:: This script will run psshutdown.exe and shutdown all 32 pcs in room E2
:: It will also produce a log (E2shutdownlog.txt) with the time and date stamp for each pc.
::The script will also delete the log file when it starts to get too big.
@echo off
cls
title E2 Power off Script
echo ---------------------
echo - Power off Script -
echo ---------------------
psshutdown.exe -t 10 -l
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc01
echo. E2 PC No.1 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc02
echo. E2 PC No.2 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc03
echo. E2 PC No.3 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc04
echo. E2 PC No.4 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc05
echo. E2 PC No.5 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc06
echo. E2 PC No.6 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc07
echo. E2 PC No.7 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc08
echo. E2 PC No.8 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc09
echo. E2 PC No.9 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc10
echo. E2 PC No.10 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc11
echo. E2 PC No.11 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc12
echo. E2 PC No.12 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc13
echo. E2 PC No.13 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc14
echo. E2 PC No.14 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc15
echo. E2 PC No.15 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc16
echo. E2 PC No.16 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc17
echo. E2 PC No.17 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc18
echo. E2 PC No.18 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc19
echo. E2 PC No.19 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc20
echo. E2 PC No.20 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc21
echo. E2 PC No.19 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc22
echo. E2 PC No.21 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc23
echo. E2 PC No.22 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc24
echo. E2 PC No.23 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc25
echo. E2 PC No.24 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc26
echo. E2 PC No.25 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc27
echo. E2 PC No.26 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc28
echo. E2 PC No.27 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc29
echo. E2 PC No.28 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc30
echo. E2 PC No.29 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc31
echo. E2 PC No.31 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc32
echo. E2 PC No.32 >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
echo. |time |find "current" >> E2shutdownlog.txt
echo. |date |find "current" >> E2shutdownlog.txt
----- >> E2shutdownlog.txt
Echo. View E2shutdownlog.txt for details
pause
Exit
it works but its slow and i need to check to see if each pc off after the command has been sent.
I can do this with a ping script but that is a separate script.
btw i know its a mess, Im qyite new to writing batch files.
Thanks
Kenny

FOR /L %%a IN (1,1,32) DO (PING \\e2pc%%a >NUL 2>&1 && echo %%a UP || echo %%a down) >> E2shutdownlog.txt
?

ok that looks very complex could you please explain how that works and what it will do to the script i posted.
thanks very much for your help.
Kenny

lol
Im sorry i just read my post again and i did not say that i have a working ping script.
my problem is combining the two so i can ping a pc to see if its on or not and if it is use the "psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 \\e2pc31" part of the script.
sorry about that.
Kenny

echo ***********************************
echo E2PC01
echo ***********************************
ping -n 1 E2PC01 >null
goto %errorlevel%
:1
echo Pc Not Responding
goto :ENDtest
:0
psshutdown.exe -m "This computer is Shutting down, please save any work" -c -t 40 \\e2pc01
echo. E2 PC No.1 >> E2shutdownlog.txt
:ENDtest
echo.should that work?

Here's my (untested) version. It's 6 lines long.
@ECHO OFF
FOR /L %%a IN (1,1,32) DO (PING -n 1 \\e2pc%%a > NUL 2>&1 || CALL :shutdown \\e2pc%%a) > E2shutdownlog.txt:shutdown
ECHO ************* - %1 - %DATE% %TIME%
psshutdown.exe -m "This computer is Shutting down, please save any work" -c - n 10 -t 40 %1

I will give that a go at the end of the day and let you know how i get on.
btw if i change the "e2pc" to "w20pc"
will it work for room W20 ?
just a thought?
Thanks very much once again :~)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |