Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

hi,

 

I am looking for a script that will ping an ip address. If it does not get a reply i would then like it to run a batch file

 

Can anyone help please?

 

Thanks

 

Z

Posted

ping -n 1 -l 1 targetip
if %errorlevel%==0 echo Host is up!
if %errorlevel%==1 goto DOWN

:DOWN
Do stuff here
And more stuff

 

Should work.

Posted
ping -n 1 -l 1 targetip
if %errorlevel%==0 echo Host is up!
if %errorlevel%==1 goto DOWN

:DOWN
Do stuff here
And more stuff

 

Should work.

 

 

Is that a batch file?

 

Thanks

Posted

Batch code, yep. Change targetip for whichever IP address you're wanting to check, and put the code you want to execute if it fails under the label.

 

In fact, thinking about it, this might be better -

 

ping -n 1 -l 1 targetip
if %errorlevel%==0 goto END

Do stuff here
And more stuff

:END

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...