| 1. |
Solve : Networking Batch File? |
|
Answer» Dear All, Hmm,,, I tested my last contribution and it works fine. What do you see on the screen?Quote from: foxidrive on April 18, 2013, 03:46:01 AM I tested my last contribution and it works fine. What do you see on the screen?From what I can see, the code the OP posted is not your most recent contribution, but is just the code from lemonilla with the loop removed. Maybe the OP wants to run the EXE file when the connection is down, and then continue to test for a connection, but only run the EXE once. That is complicated by the fact that the connection could flutter and go up and down rapidly. We'd need to know how he wants to handle that.Hi All, Below is my Query to make a batch file : 1. My ping to Google.com should continuously be on so that i can see the reply from the site 2. As my link goes down (Request time out) it should give me an pop of an .exe file (which i have made) only once, and it should continuously check the connection when it comes up. Regards, Saravanan My ping isn't working in general, try this out, and see if it works (or if it's close to what you want.) Code: [Select]@echo off set a=0 :loop ping www.google.com -n 1 >nul 2>&1 if "%errorlevel%"=="0" set a=0 if "%errorlevel%"=="1" if "%a%"=="0" call :loss goto loop :loss start FILE.exe set a=1 goto :eof Hi Lemonilla, the command which u gave me last one, when ever i used to run it, it just shows blank cmd screen. Please help me on the below command : ******************************************************************************* @echo off :PING ECHO Checking connection, please wait... PING -n 1 www.google.com|find "Reply from " >NUL IF NOT ERRORLEVEL 1 goto :SUCCESS IF ERRORLEVEL 1 goto :TRYAGAIN :TRYAGAIN ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO FAILURE! ECHO Let me try a BIT more, please wait... @echo off start /d "c:\Ping files\Link Files" et.exe PING -n 3 www.google.com|find "Reply from " >NUL IF NOT ERRORLEVEL 1 goto :SUCCESS IF ERRORLEVEL 1 goto :FAILURE :SUCCESS ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO You have an active Internet connection ping www.google.com -w 4 goto PING :FAILURE ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO Kindly Check the connection.........! ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- goto PING sleep 20 :END ******************************************************************************* When i run the above batch file I get: "Please see the screen shot 1.jpg as attached" and when i disconnect my network cable I get: "Please see the screen shot of 2.jpg as attached" So in this i just want that it should display only once the error "ET link is down" when the link goes down. and it should keep checking the link status.... So can you please modify on the above program and resend at the earliest. Hope you got my needs Thanks, Regards, Saravanan [recovering disk space, attachment deleted by admin]try: Code: [Select]@echo off set a=0 :PING ECHO Checking connection, please wait... PING -n 1 www.google.com|find "Reply from " >NUL IF NOT ERRORLEVEL 1 goto :SUCCESS IF ERRORLEVEL 1 goto :TRYAGAIN :TRYAGAIN ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO FAILURE! ECHO Let me try a bit more, please wait... @echo off if "%a%"=="1" start /d "c:\Ping files\Link Files" et.exe PING -n 3 www.google.com|find "Reply from " >NUL IF NOT ERRORLEVEL 1 goto :SUCCESS IF ERRORLEVEL 1 goto :FAILURE :SUCCESS set a=1 ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO You have an active Internet connection ping www.google.com -w 4 goto PING :FAILURE set a=0 ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO Kindly Check the connection.........! ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- goto PING %a% holds the value of the last ping (success/failure). When it checks to run your exe, it checks to see if the last ping was a failure, and then does not run. About the blank screen, I did that purpusfuly, as I figured it would run in the background and would be annoying with lots of flashing text. Here is some with text: Code: [Select]@echo off set a=1 :loop ping www.google.com -n 1 >nul 2>&1 if "%errorlevel%"=="0" ( if "%a%"=="1" cls if "%a%"=="1" echo Connected set a=0 ) if "%errorlevel%"=="1" if "%a%"=="0" call :loss goto loop :loss cls echo Connection Error. echo Reconnecting. . . start /d "c:\Ping files\Link Files" et.exe set a=1 goto :eof It should write only "Connected" while connected, and write "Connection Error. Reconnecting. . . " while not. You will have to test it to check though. Also changed 'start FILE.exe' to 'start /d "c:\Ping files\Link Files" et.exe' from your code.[/code]alt + printscreen for screen shots!Hi Lemonilla, Awesome...... it has started working, thanks a lot, it was a excellent help by you... One last thing in the last program you have edited and send to me... in that when the .exe file runs can that .exe file is it possible to display on the other computer which is in the network. Regards, Saravanan. U |
|