Computing.Net > Forums > Programming > Batch File - Ping > Send Command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Batch File - Ping > Send Command

Reply to Message Icon

Name: xeroliun
Date: April 27, 2008 at 11:03:19 Pacific
OS: Windows XP
CPU/Ram: AMD
Product: Elitegroup
Comment:

Hello, I am kindly looking for a batch file that will do the following.

1. I have a list of 10 PC names in a text file (pcnames.txt)

2. I want to ping every PC name in the list

3. If the ping fails then put the failed PC name into a text file (failedping.txt)

4. If ping succeeds then remove a directory on the success PC (ex. rmdir c:\VNC /s /q)

Thank you,
X.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: April 27, 2008 at 19:23:01 Pacific
Reply:

Not tested

::===============================
@echo off > failedping.txt
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (pcnames.txt) do (
ping %%a | find "Reply" > nul
if errorlevel 1 (echo %%a >> failedping.txt
) else (
echo rd //%%a/c:/VNC /s /q
)
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: xeroliun
Date: April 28, 2008 at 04:36:31 Pacific
Reply:

Thanks M2, I really appreciate it.

Minor tweaking of the RD command on the last line, and it works PERFECTLY:

@echo off > failedping.txt
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (pcnames.txt) do (
ping %%a | find "Reply" > nul
if errorlevel 1 (echo %%a >> failedping.txt
) else (
rd \\%%a\c$\VNC /s /q
)
)

-----

Thanks again, I feel honored to be helped by the Master M2!

X.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


VB6 Puzzle VB script to copy folders



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: Batch File - Ping > Send Command

batch files , ping results www.computing.net/answers/programming/batch-files-ping-results/14790.html

Need Help with DOS batch file .. www.computing.net/answers/programming/need-help-with-dos-batch-file-/12751.html

Batch file, ping results www.computing.net/answers/programming/batch-file-ping-results/14033.html