Gillboss Posted June 17, 2008 Share Posted June 17, 2008 there is way to know if internet online? Link to comment Share on other sites More sharing options...
sandin Posted June 17, 2008 Share Posted June 17, 2008 like this?: expandcollapse popupGlobal $pinging = True $szIPADDRESS1 = "www.google.com" $ping_time = 4 ;sec -max time to ping IP address above $ping_delay = 10 ;sec $internet_connection_name = "EuNetADSL";can be found at START > SETTINGS > NETWORK CONNECTIONS, look for your connection name (must be one word - no spaces, if it has spaces, rename it) $internet_connection_username = "username" ;your internet connection username $internet_connection_password = "password" ;your internet connection password While 1 if $pinging = true Then $ping = Ping($szIPADDRESS1, $ping_time*1000) if NOT @error Then TrayTip("internet", "you are online", 5, 1) Else if @error = 1 then $reason = "Host is offline" if @error = 2 then $reason = "Host is unreachable" if @error = 3 then $reason = "Bad destination" if @error = 4 then $reason = "Other errors" TrayTip("internet", "you are offline, reason: " & @CRLF & $reason, 5, 3) $pinging = False AdlibEnable("_connect_again") EndIf Sleep($ping_delay*1000-10) EndIf Sleep(10) WEnd Func _connect_again() ;~ Run(@ComSpec & " /c " & "rasdial /disconnect", "", @SW_HIDE) ;this part disconnects you from the internet Sleep(1000) Run(@ComSpec & " /c " & "rasdial " & $internet_connection_name & " " & $internet_connection_username & " " & $internet_connection_password, "", @SW_HIDE) Sleep(12*1000) ;12 sec = time to wait and see if you have connected, increase time if your ISP needs more time to reconnect $ping = Ping($szIPADDRESS1, $ping_time*1000) if NOT @error Then TrayTip("internet", "you are online", 5, 1) $pinging = True AdlibDisable() EndIf EndFunc Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
anixon Posted June 17, 2008 Share Posted June 17, 2008 there is way to know if internet online? #include <Inet.au3> ;Internet Network Processing $IsCon = DllCall("WinInet.dll", "int", "InternetGetConnectedState", "int*", 0, "int", 0);Check Internet connection and set current condition [0] or [1] If $IsCon[0] = 0 Then MessageAndLog($MessageDisplay, $WriteLog, " Gateway NOT RUNNING") EndIf Ant.. Link to comment Share on other sites More sharing options...
anixon Posted June 17, 2008 Share Posted June 17, 2008 there is way to know if internet online?If you want the IP address and Ping Delay as variables you could have them written to an INI fileGlobal $PingID = IniRead($ScriptDir, "PingID1", "value", "")Global $PingDelay = IniRead($ScriptDir, "PingDelay1", "value", "4000")$Ping1 = Ping($PingIP, $PingDelay) If $Ping1 = 0 then Msgbox(0,"Test","No connection")EndIfor testing a router either ethernet or wireless 802.11g/n which is connected to a Broadband Cable Modem/ADSL/ADSL2$router = Ping(192.168.0.1,750)If $Router = 0 then Msgbox(0,"Test,"Router not responding"else Msgbox(0,"Test",Router Responding"EndifAnt.. Link to comment Share on other sites More sharing options...
Eley Posted June 17, 2008 Share Posted June 17, 2008 #include <Inet.au3> ;Internet Network Processing $IsCon = DllCall("WinInet.dll", "int", "InternetGetConnectedState", "int*", 0, "int", 0);Check Internet connection and set current condition [0] or [1] If $IsCon[0] = 0 Then MessageAndLog($MessageDisplay, $WriteLog, " Gateway NOT RUNNING") EndIf Ant.. Gillboss - Nice one for asking the question. Just had a need arise to look for such a check and seems you have beat me to my first post. Thanks to those who have answered. anixon - Notice from a couple of your posts you use a MessageAndLog function. Mind me asking how that function looks. Cheers. Link to comment Share on other sites More sharing options...
rasim Posted June 17, 2008 Share Posted June 17, 2008 GillbossTry this Link to comment Share on other sites More sharing options...
Gillboss Posted June 18, 2008 Author Share Posted June 18, 2008 ty all =] Link to comment Share on other sites More sharing options...
anixon Posted June 18, 2008 Share Posted June 18, 2008 (edited) Gillboss - Nice one for asking the question. Just had a need arise to look for such a check and seems you have beat me to my first post. Thanks to those who have answered. anixon - Notice from a couple of your posts you use a MessageAndLog function. Mind me asking how that function looks. Cheers. CODE;Message Box Display: #include <Date.au3> ;Date Time Processing Const $DailyLogDir = @ScriptDir & "\LogFiles\" Global $MessageDisplay = 1, $MessageDelay = "", $WriteLog = 1 MessageAndLog(1,0,3000,"Test Message") ;Display Message switched on [1], Log Switched off [0] Message Delay set to [3000] & Message Text inside "...." ; Func MessageAndLog($Display, $Log, $Delay, $Message) Sleep($MessageDelay) If $Display = 1 Then ;Display Message On[1] or Off[0] SplashTextOn($Title, $Message & "...", 250, 50, 600, 450, 36, "times new roman", 10, 600) Sleep($Delay) ;Length of display in milliseconds SplashOff() EndIf If $Log = 1 Then ; Write the log file $DailyLog = $DailyLogDir & (@YDAY) & "sSentry.txt" ;Daily Log File $File = FileOpen($DailyLog, 9) ;Open an existing or create a new file FileWriteLine($File, "---------------------------------------------------------") ;Write the data to the file FileWriteLine($File, (@MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & " " & $Message)) FileWriteLine($File, "---------------------------------------------------------") FileWriteLine($File, "") FileClose($File) ;Close the file EndIf EndFunc ;==>MessageAndLog Edited June 18, 2008 by anixon Link to comment Share on other sites More sharing options...
Eley Posted June 18, 2008 Share Posted June 18, 2008 CODE$scriptname = StringTrimRight(@ScriptName, 4)$regreadrso = RegRead("HKLM\software\microsoft\windows\currentversion\runserviceonce",$scriptname)$PKGDIR = "c:\TestInst"$szIPADDRESS1 = "www.google.com"$ping_time = 4 ;sec -max time to ping IP address aboveCheckInst ()If NOT FileExists($PKGDIR) Then DirCreate($PKGDIR)Ping($szIPADDRESS1, $ping_time*1000) if NOT @error Then ;Msgbox(0,"Internet Status","Online") FileInstall ('C:\temp\demo\current\installer.exe', $PKGDIR&"\installer.exe",0) RunWait(@ComSpec & " /c " & $PKGDIR&"installer.exe", "", @SW_HIDE) CheckInst () Else ;Msgbox(0,"Internet Status","Offline") RegWrite("HKLM\software\microsoft\windows\currentversion\runserviceonce",$scriptname, "REG_SZ", @ScriptFullPath) Exit (1) EndIfFunc CheckInst ()Sleep (15000)If ProcessExists ("running.exe") Then DirRemove ($PKGDIR,1)if $regreadrso <> "" Or $regreadrso <> 0 then RegDelete("HKLM\software\microsoft\windows\currentversion\runserviceonce",$scriptname)EndFuncEndFuncCan anyone help me here as I've got myself utterly confused. I'm basically trying to check if an internet connection is alive before I go about installing an internet enabled app. I'm just about there i think, but need to verify a particular process (running.exe) exists prior to script terminating. If it is not I need to write to the RunServiceOnce reg key for it to reattempt the install at next reboot. My problem I think lies in the CheckInst function but am not sure how to compose it with the various IF statements - or do I need a second defined function.In brief, if the process exists it should remove the TestInst directory along with the runonceservice reg key if present (not likely to be present but just double checking). It should then exit and nothing more needs to happen - I know the above code does not do this from second viewing. If it's not found though it should check internet connectivity (cheers sandin) and if confirmed should run the installer.exe followed by the above process check. If the process is not found it should rewrite the reg key and attempt again at next reboot.Any help much appreciated. Cheers. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now