hi,
i wrote a batch that runs on windows user logon and pings a website. if ping is succesful, it starts various tools (like mail icq etc). otherwise if i'm offline i don't need those tools running on my notebook.
but now i want to enhance this batch. i know there is a tool called srvany.exe which makes it possible to run a bat(oder exe) file as a service. yet i dont know whats the best way to write a batch which constantly checks if internet-connection is available. or should i keep pinging that website forever? maybe one of you know of another option for me to solve this issue, because i'm still new to batch scripting.
thanks in advance.
batch checks internet connection
Moderator: DosItHelp
Re: batch checks internet connection
Hi,
to the specifications i have made the batch script for you,
you need to change in one line while you execute the code,
it is the path of your srvany.exe ,
echo statements are for your undersanding purpose,
the code was
connect.bat
@echo off
set server=www.google.com
:check
ping %server% > NUL
if %ERRORLEVEL%==0 (
@echo internet was conncted
goto working
) else (
@echo internet was notconnected
goto check
)
:working
echo write code to call srvany.exe
:update
ping %server% > NUL
if %ERRORLEVEL%==0 (
@echo internet was connected
goto update
) else (
@echo internet was notconnected
goto check
)
@echo on
//this executes continuously, updates connection for every time and calls srvany.exe only once after getting internet connection
to the specifications i have made the batch script for you,
you need to change in one line while you execute the code,
it is the path of your srvany.exe ,
echo statements are for your undersanding purpose,
the code was
connect.bat
@echo off
set server=www.google.com
:check
ping %server% > NUL
if %ERRORLEVEL%==0 (
@echo internet was conncted
goto working
) else (
@echo internet was notconnected
goto check
)
:working
echo write code to call srvany.exe
:update
ping %server% > NUL
if %ERRORLEVEL%==0 (
@echo internet was connected
goto update
) else (
@echo internet was notconnected
goto check
)
@echo on
//this executes continuously, updates connection for every time and calls srvany.exe only once after getting internet connection
Re: batch checks internet connection
@shiva
Kinda long...
:/
Kinda long...
Code: Select all
@echo off
ping google.com > nul && (echo You are connected to the internet!) || (echo You are not connected to the internet!)
pause
:/
Re: batch checks internet connection
Hi,
i just write the code to get u understand,
i doesnt thing of making small
i just write the code to get u understand,
i doesnt thing of making small