Solved

Script or command to ping active nic gateway

Posted on 2014-11-10
3
155 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 69

Accepted Solution

by:
Qlemo earned 500 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 69

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is there a way to automate exercising the network using a browser 3 79
Need a cheap RFID setup 10 110
Setting up a VPN 60 205
Skype password reset 1 32
Trying to figure out group policy inheritance and which settings apply where can be a chore.  Here's a very simple summary I've written which might help.  Keep in mind, this is just a high-level conceptual overview where I try to avoid getting bogge…
An article on effective troubleshooting
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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