Jump to content

Recommended Posts

Posted

can anyone tell me the easiest/shortest way to check if the computer is online? only ways i can come up with is assorted ip- and net- commands in CMD, but im sure theres a better way that takes up only a line or two. thanks.

Posted

No, that only checks if a different computer is online, it automatically returns 5 whether this computer is on or not. (i want to see if THIS computer has a current internet connection, not a different computer. thanks anyways

Posted (edited)

here we are (untested)

Edit: Tested! I inverted the 0 and the 1, ops... Now works. :whistle:

Func _IsThisComputerConnected()

; A function to know if a computer is connected or not.
; Returns
; 0 if the computer is Offline
; 1 if the computer is Online

Local $ping
Local $computername

$computername = "www.altavista.com";----Altavista seems a good computer to check... :)

; Changed -w to 5000 because a "out-of-LAN" computer can need more time.
RunWait(@comspec & " /c ping "& $computername &" -n 1 -w 5000>"& @tempdir &"\ping.tmp","",@sw_hide)
$ping = FileReadLine(@tempdir &"\ping.tmp",13)
FileDelete(@tempdir &"\ping.tmp")
If StringInStr($ping,"(0%") Then
   Return 1
Else
   Return 0
EndIf
EndFunc
Edited by ezzetabi
Posted (edited)

You are forgetting an important, but easy to miss, fact that someone's computer may be behind a proxy. Then the ping command would never be successfull...it's not for me.

There is an API command for getting internet connection status.

Edited by MattNis

[quote]I was busy waiting all night for the Columbus Day Bunny to come down my chimney and light fireworks in my pumpkin.There's so much wrong with that.Oh, I'm sorry, i forgot you were Jewish.[/quote]

Posted

If you're simply checking your connectivity to the internet .. then why not just run a URLDownloadToFile (of say, www.google.com) .. and check the results? :whistle:

Posted

There is an API call to check if computer is connected to the internet.

Any plans on incorporating it?

[quote]I was busy waiting all night for the Columbus Day Bunny to come down my chimney and light fireworks in my pumpkin.There's so much wrong with that.Oh, I'm sorry, i forgot you were Jewish.[/quote]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...