Hey guys,
I'm making a script wich opens a file (at random), but this file is placed on a remote disk. So i want to ping the IP adress to make shure there's connectivity. If there is connectivity it should open a file on the remote disk, else it should open a local file. I got the open file part all worked out, its only the if/else part i need.
ping 129.168.1.2
if "succes"
*open remote file *
else
*open local file *
Is it possible and if so, could you help me with that?
Thnx
IF ELSE statement based on ping result
Moderator: DosItHelp
Re: IF ELSE statement based on ping result
You could use the ERRORLEVEL, or maybe more simple: && (command was successful) and || (command failed)
Regards
aGerman
Code: Select all
@echo off
ping -n 1 129.168.1.2 >nul &&(
*open remote file *
)||(
*open local file *
)
Regards
aGerman
-
- Posts: 2
- Joined: 06 Dec 2010 15:28