DOS Command  OR Scripts

Posted on 2013-11-19
Last Modified: 2013-12-04
Hi EE,

I am looking for the scripts or command to ping the list servers that located in domain from text or excel file and get the result in notepad, Could any one help on this? Please and Thank you

J Peter
Question by:Jey_P
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 67

Accepted Solution

sirbounty earned 100 total points
ID: 39659804
From a command line:
for /f %a in (c:\servers.txt) do ping %a -n 1 >> results.txt

or in a batch file:

@echo off
for /f %%a in (c:\servers.txt) do ping %%a -n 1 >> results.txt

Open in new window

LVL 84

Assisted Solution

oBdA earned 50 total points
ID: 39659814
Batch file that creates a csv:
@echo off
set ServerFile=Servers.txt
set LogFile=%~dpn0.csv
set CsvDelim=,
if exist "%LogFile%" del "%LogFile%"
for /f %%a in ('type "%ServerFile%"') do (
	echo Processing %%a ...
	ping -4 -n 4 %%a | find /i "TTL" >NUL
	if errorlevel 1 (
		>>"%LogFile%" echo %%a%CsvDelim%Error 
		echo ... offline.
	) else (
		echo ... responding.
		>>"%LogFile%" echo %%a%CsvDelim%Success
echo Done.
start "" notepad.exe "%LogFile%"

Open in new window

LVL 13

Expert Comment

ID: 39659828
Hope it will help
@echo off

REM cd "c:\your location if you need"
for /f "tokens=* delims=" %%x in (d:\ping.txt) do ping %%x

Open in new window

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

LVL 40

Assisted Solution

Subsun earned 50 total points
ID: 39659837
Wit PowerShell...
GC C:\Server.txt | % {
$Server = $_
 If (Test-Connection $Server -Quiet){
	 New-Object PSOBJect -Property @{
	 Server = $Server
	 Status = "UP"
	 New-Object PSOBJect -Property @{
	 Server = $Server
	 Status = "Down"
} | Export-Csv C:\report.csv -nti

Open in new window

Input file..

Open in new window

LVL 13

Assisted Solution

duncanb7 earned 25 total points
ID: 39659863
it works with less code
@echo off
del -f out.txt
REM cd "c:\your location if you need"
REM ping.txt store all your server name
for /f "tokens=* delims=" %%x in (c:\ping.txt) do ping %%x>>out.txt
start  notepad.exe "out.txt"

Open in new window

LVL 15

Assisted Solution

by:David L. Hansen
David L. Hansen earned 25 total points
ID: 39659867
You can use MS Powershell to do this (and it's free).  Here are a couple of links to show you where people are already doing exactly the same thing you are trying.

It is included in the Windows Management Framework download here.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question