?
Solved

Script or command to ping active nic gateway

Posted on 2014-11-10
3
Medium Priority
?
158 Views
Last Modified: 2014-11-10
I have an application that displays a system tray icon that can reference a command or a script for troubleshooting steps for end users. Pinging the default gateway is a step I would like to add without customizing each application installation for each clients network. Any ideas?
0
Comment
Question by:emconsulting
[X]
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
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 40433321
Something simple:
@echo off
setlocal EnableDelayedExpansion
set IP=
FOR /F "tokens=2 delims=:" %%a IN ('ipconfig ^| findstr /IC:"Default Gateway"') DO (
  if NOT "%%a" == " " ping %%a -n 1
)
exit /b

Open in new window

0
 

Author Comment

by:emconsulting
ID: 40433347
Thank you. I need the results do display to the user. What would I add to the code? I also saved this as a .bat file, is that correct?
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 40433364
.bat or .cmd does not matter, though I prefer latter.
You probably just need the script to pause until a key is pressed to allow for viewing the result. Replace the exit /b with pause.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

FIPS stands for the Federal Information Processing Standardisation and FIPS 140-2 is a collection of standards that are generically associated with hardware and software cryptography. In most cases, people can refer to this as the method of encrypti…
Have you ever set up your wireless router at home or in the office to find that you little pop-up bubble in the bottom right-hand corner of Windows read "IP Conflict - One of more computers on the network have been assigned the following IP address"…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

771 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