Hi all,
PROBLEM:
I am using the same internet connection with two other persons. In order to not overuse our shared bandwith i would like a script/batch file, etc that checks if any of the two is online. if non of them is online, a download should start automatically (via program target.exe).
if on the other hand one of them goes online(meaning they start their computers) the download manager should stop (i wouldnīt mind just killing the process, if that makes it any easier.).
so this script/or batch file would need to check every ~15 min if one of them is online.
I thought about realizing it with a small batch script and just use a successful ping as a sign of them being online. unfortunately my programming skills - even with batch files - are very limited. so i would really appreciate your help on this.
In case I am trying to invent something, that already exists, please point me to it.
FIRST TRY:
so far i have reached this solution for my problem.
process is a little tool i used to kill a process from commandline. and the last ping is just to put a little delay in the whole thing. the rest should be self explaining.
But: It sometimes hangs, e.g. when i pull out my network cable. i donīt know why, but it would be great if in case of hangup the program would restart itself.
also, as you may have noticed, in case of "dead" the target application will start every time the check is performed succesfully. does anybody know how to tell the batch file not to start a process if it is already running?
And one last thing, would it be possible to run this as a background process, without appearing in the taskbar.
I would really appreciate any support on this. thanks in advance.
Code of Batch file es.bat
ECHO OFF
cd %windir% > nul
:pingfabi
@ping 192.168.2.10 -n 1 > nul
@IF ERRORLEVEL 1 GOTO pingtobi
@IF ERRORLEVEL 0 GOTO alive
:pingtobi
@ping 192.168.2.118 -n 1
@IF ERRORLEVEL 1 GOTO pingnils
@IF ERRORLEVEL 0 GOTO alive
:pingnils
@ping 192.168.2.150 -n 1 > nul
@IF ERRORLEVEL 1 GOTO dead
@IF ERRORLEVEL 0 GOTO alive
:dead
@C:\programme\target\target.exe > nul
@GOTO end
:alive
@process -q target.exe > nul
@GOTO end
:end
ECHO *
ping 127 -n 1
es.bat