connect or disconnect
Moderator: DosItHelp
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
connect or disconnect
I want to write a batch file that tell me i am connected to the internet or disconnected.
by using "ping" and "erorlevel"
by using "ping" and "erorlevel"
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: connect or disconnect
someone answer me!!!
Re: connect or disconnect
hai
i am unable to get the server address with batch programming,
but using google site as server i made the batch file,
this will not effect any other server address
the batch file is as follows:
@echo off
set server=www.google.com
ping %server%
if %ERRORLEVEL%==0 (
@echo internet was connected
) else (
@echo internet was notconnected
)
@echo on
pause
this will show the internet connectivity,
if you are intrested change your local subscriber address as server address,
thank you
shiva
i am unable to get the server address with batch programming,
but using google site as server i made the batch file,
this will not effect any other server address
the batch file is as follows:
@echo off
set server=www.google.com
ping %server%
if %ERRORLEVEL%==0 (
@echo internet was connected
) else (
@echo internet was notconnected
)
@echo on
pause
this will show the internet connectivity,
if you are intrested change your local subscriber address as server address,
thank you
shiva
Re: connect or disconnect
... or something like that:
Regards
aGerman
Code: Select all
@echo off
ping -n 1 google.com >nul &&(
echo connected
) || (
echo disconnected
)
pause
Regards
aGerman
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: connect or disconnect
aGerman wrote:... or something like that:Code: Select all
@echo off
ping -n 1 google.com >nul &&(
echo connected
) || (
echo disconnected
)
pause
Regards
aGerman
@aGerman
Could you explain how this script is working, I am fumbling with the concept of ) || (
Thank you.
Re: connect or disconnect
command1 && command2
command2 will be executed if command1 was successful (ErrorLevel is 0)
command1 || command2
command2 will be executed if command1 failed (ErrorLevel not 0)
command1 && command2 || command3
command2 will be executed if command1 was successful, else command3 will be executed.
Regards
aGerman
command2 will be executed if command1 was successful (ErrorLevel is 0)
command1 || command2
command2 will be executed if command1 failed (ErrorLevel not 0)
command1 && command2 || command3
command2 will be executed if command1 was successful, else command3 will be executed.
Regards
aGerman
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: connect or disconnect
@aGerman
Thank You.
Thank You.
Re: connect or disconnect
You're welcome.
I had a c/p failure in my 2nd example ... fixed.
Regards
aGerman
I had a c/p failure in my 2nd example ... fixed.
Regards
aGerman
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: connect or disconnect
thank u shiva
thank u aGerman
thank u aGerman
Re: connect or disconnect
you are welcome dude...........,