Answer» 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
Code: [Select]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 I think making a program that allow what you want to do is more effective but with the lac of knowlege it is hard to make it come true. Try some network monitoring softwareThanks for your answer.
The Batch file is up and working. But since it is not really a nice solution, I decided to get into programming with c++ to figure out a nicer solution. This is not gonna HAPPEN anytime soon, but its always nice to have something to look forward to... ;-)
Quote Thanks for your answer.
The Batch file is up and working. But since it is not really a nice solution, I decided to get into programming with c++ to figure out a nicer solution. This is not gonna happen anytime soon, but its always nice to have something to look forward to... ;-)
Yes, you can do this with C++. Once you learn some BASICS, google winsock tutorials
|