Sign in to follow this  
Followers 0
insanepyrokid

Check If Computer Is Online

8 posts in this topic

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.

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

OK ... understand what you meand now...

Could you check the @IPAddress1 thru @IPAddress4 to see if it gets and address assigned from you ISP ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  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

Share this post


Link to post
Share on other sites

#6 ·  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]

Share this post


Link to post
Share on other sites

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:

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0