Computing.Net > Forums > Programming > Help with my psshutdown bat file?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Help with my psshutdown bat file?

Reply to Message Icon

Name: kenny2001
Date: September 18, 2007 at 00:48:01 Pacific
OS: multi
CPU/Ram: multi
Product: multi
Comment:

:: 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



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: September 18, 2007 at 17:46:19 Pacific
Reply:

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


0

Response Number 2
Name: kenny2001
Date: September 19, 2007 at 00:23:03 Pacific
Reply:

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


0

Response Number 3
Name: kenny2001
Date: September 19, 2007 at 00:33:56 Pacific
Reply:

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


0

Response Number 4
Name: kenny2001
Date: September 19, 2007 at 00:38:54 Pacific
Reply:

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?


0

Response Number 5
Name: Razor2.3
Date: September 19, 2007 at 01:17:01 Pacific
Reply:

It should, but there's much cleaner ways to get it done.


0

Related Posts

See More



Response Number 6
Name: kenny2001
Date: September 19, 2007 at 02:19:58 Pacific
Reply:

well i did say i was new to this :)


0

Response Number 7
Name: Razor2.3
Date: September 19, 2007 at 03:36:21 Pacific
Reply:

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


0

Response Number 8
Name: kenny2001
Date: September 19, 2007 at 04:49:35 Pacific
Reply:

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 :~)


0

Response Number 9
Name: Razor2.3
Date: September 21, 2007 at 19:46:05 Pacific
Reply:

will it work for room W20 ?
Yep.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Help with my psshutdown bat file?

Backup strategy and bat file help www.computing.net/answers/programming/backup-strategy-and-bat-file-help/17442.html

Help with my Scheme Program!!! www.computing.net/answers/programming/help-with-my-scheme-program/3344.html

Help with my C++ program www.computing.net/answers/programming/help-with-my-c-program/1813.html