Computing.Net > Forums > Programming > shutdown server in an order

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.

shutdown server in an order

Reply to Message Icon

Name: nuganen
Date: November 4, 2007 at 17:39:20 Pacific
OS: winxp pro
CPU/Ram: 1gb
Product: hp
Comment:

Hi,

I'm trying to write a batch file that shutdown servers in a sequential order however having an issue at the moment think it has to do with the ping command

this is what i have so far

@echo on

REM -s is shutdown
REM -m is pc
REM -t is time
REM -c is comments

REM shutdown server from a list
FOR /F %%A IN (server.txt) DO (

shutdown -s -m \\%%A -t 120

call :keeppingingdamnyou

)
GoTo :EOF

:keeppingingdamnyou
ping -n 1 %%A|find /i "TTL=" >NUL
if %errorlevel%==1 goto keeppingingdamnyou
net send user "%%A is down!"

cheers



Sponsored Link
Ads by Google

Response Number 1
Name: nuganen
Date: November 4, 2007 at 18:48:22 Pacific
Reply:

the %errorlevel%=0 not 1 it was a typo


0

Response Number 2
Name: Razor2.3
Date: November 4, 2007 at 19:15:24 Pacific
Reply:

Q: Aside from a needless use of FIND, what's wrong, exactly?

A: Your use of %%A in your function. Use %1 instead, and replace the call with CALL :keeppingingdamnyou %%A.

Side note: ping -n 1 %%A >NUL &&GOTO keeppingingdamnyou is easier to type.

EDIT: Actually, there's also a problem with your IF statement. Namely, it triggers only if the server is down. (Read: The exact opposite of what you were looking for.)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: shutdown server in an order

Perl, compare lines in an array www.computing.net/answers/programming/perl-compare-lines-in-an-array/14724.html

Dump a tree in C++ www.computing.net/answers/programming/dump-a-tree-in-c/1596.html

Web Server in Visual Basic www.computing.net/answers/programming/web-server-in-visual-basic/10606.html