Require shutdown managing software

Status
Not open for further replies.

hansraj

In the zone
Guys i am in search for software which can give me the option of shutdown/restart if my pc fails to get connected to internet or loses internet connectivity (due any reason). Also any application which can trigger off my desired application (batch file for shutdown), the moment internet connectivity is lost, will also do the job. I googled but most of the available softwares are giving me the options except for this internet connectivity. If someone has made personnel software that too is welcome (Mera haath programming me zara tang hai but i think it will not require long time for making a code for same).
 
OP
hansraj

hansraj

In the zone
Thanks for the reply......... in fact u and me appear to be doing the same thing and we shouldnt be surprised that all those who are using the night unlimited downloads have to resort to such kind of method, no one can wake up at night 2:00. However my problem still remains..... if u read my post carefully then i want a software which has to check if i am connected to net or not. And if not then it should trigger restart or run my desired application.(At times the router fails to connect despite repeated attempts for which the router needs to be restarted and i have arranged the set up at home in such a way that when my pc starts then only the router starts so restarting the PC would restart my router as well and then rest of the things will be taken care of by the windows scheduler again)
 

dheeraj_kumar

Legen-wait for it-dary!
Ah yes... Pardon me for not reading the post properly. I just read the first line, and assumed. Anyway, the conditions are similar. We are doing the same thing, and the only difference is,
I reset my router so that I can connect to BSNL via PPPOE dialer, and if there is any connection problem it will reconnect automatically
and you havent, so your modem might not reconnect automatically. So you want to restart or run or shutdown or whatever.

I dont understand hindi, so I dont get what you're talking about programming in your post. However, its simple to do it if you can. There is a function called InternetGetConnectedState. MSDN at

*msdn.microsoft.com/en-us/library/aa384702(VS.85).aspx

So I figure the code may be something like:

Code:
DWORD dwNetState;
if(!InternetGetConnectedState(dwNetState, 0))
{
           //do whatever you want, its not connected. restart or whatever
}
else
           //exit program

That should do it, make this into a program and run it... say every five minutes. If it finds that there is no internet, it will restart automatically, and so will the router, and net will be restored. However, if lets say there is a BSNL problem or something, then your comp will keep on restarting forever :( So you can implement something like it writes the no. of restarts done to registry or a log file. If its lets say ten restarts but no internet, then just shut down the comp.

Anyway if you can do it, please :) If you cant, I'll try to do it for you. I'm bogged down with my university exams now, and they get over on 13th. After that, expect an entire tutorial on a completely 200% automated BSNL night downloading with torrents and HTTP downloads support :)

AND a programmer's reference too with pseudocode... so that people can actually LEARN instead of leech :)
 
Last edited:
OP
hansraj

hansraj

In the zone
thanks dheeraj for the suggestion............ meanwhile i was working on same thing and ended up making an exe file which actuall pings google.com thrice in a period of 5 seconds and as long as any one of the return is positive then the program quits or else it shutsdown. So my job is done.
However, U said that we can keep a count of the restarts and limit it to 10 or whatever i want ( in case of bsnl prob) by registry, can u be a bit elaborate on this.

U also said that u reset u r router.... how can u do that by commands???
 

dheeraj_kumar

Legen-wait for it-dary!
Not commands, I use Huawei SmartAX MT800, one of the first modems BSNL began to give out. Its a white and green device. Theres a reset switch behind the modem, and thats what I used. If you dont have one in yours, go to the administrative interface of the modem, there should be an option to reset to factory settings.

Either registry or file for storing your no. of attempts. i dont know what language you use for programming, but here is one using win32 api:
*msdn.microsoft.com/en-us/library/ms838625.aspx

This is for some other platforms, but you can see how the api is used. Refer to them on MSDN for more details.

Every time you restart, read the value from the location and increment it, and write it back. if its say ten, dont restart.

For files, just write the value on a text file or something, read it when needed.

And yeah, pinging every 5 seconds is a waste of bandwidth. Not much is lost, but its still a waste. You're better off checking the comp than checking other servers for connection.
 
OP
hansraj

hansraj

In the zone
And yeah, pinging every 5 seconds is a waste of bandwidth. Not much is lost, but its still a waste. You're better off checking the comp than checking other servers for connection.

it doesnt ping contineously as understood by u.... what it does is ping 3 times in a gap of 5 secs and then exit. i just schedule it to start it at regular interval of 30 mins so actually in one hr of connectivity it pings 6 times ... thats all
 
OP
hansraj

hansraj

In the zone
well... in that case yes. But I am lucky to be in a place where the supply remains most of the time, but this precautions are only for that unique night when the supply goes off.

Its not that i didnt try the to use the programming using Wininet.dll for internet connectivity... but its not foolproof as it results in returning positive replies even when my internet connection is lost ... what it probably looks is whether my network is on or not (i.e. connectivity to my router) and as long as my router is on it is unable to detect the internet connectivity. So I made this simple one.
 
Last edited:

dheeraj_kumar

Legen-wait for it-dary!
Oh, I get it. Since I use a dialer for net, I get 100% positive results. But since its built in your modem, all it checks is the network. Fine, then.
 
Status
Not open for further replies.
Top Bottom