Solved

Script or command to ping active nic gateway

Posted on 2014-11-10
3
152 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
  • 2
3 Comments
 
LVL 68

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 68

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change Time 5 51
Essentials 2012 static IP Changes to Obtain Automatically 6 40
How do I make our RDS server available from the Internet 5 52
Password managers 1 17
Downtime reduced, data recovered by utilizing an Experts Exchange Business Account Challenge The United States Marine Corps employs more than 200,000 active-duty Marines with operations in four continents, all requiring complex networking system…
This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now