Buffo Posted October 25, 2006 Share Posted October 25, 2006 Hi Is it possible to get the state of a ras connection without connect to the internet if no connection is available? With checking the ping time every time the internet connection will be accomplished. Regards, Buffo Link to comment Share on other sites More sharing options...
lod3n Posted October 25, 2006 Share Posted October 25, 2006 You could capture the output of an IPCONFIG /ALL command with StdoutRead and see if your RAS connection's name shows up in that output. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Buffo Posted October 25, 2006 Author Share Posted October 25, 2006 Great idea I don't have a RAS connection here. Can any one give me examples of the connected/disconnected output? Thx in advance! Regards, Buffo Link to comment Share on other sites More sharing options...
Zedna Posted October 25, 2006 Share Posted October 25, 2006 Look at my autodial_src.zip rnahelpxp_src.zipfrom my signature There are RAS API functions: RasEnumConnections RasGetConnectStatus Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Buffo Posted October 25, 2006 Author Share Posted October 25, 2006 @Zedna: Thx for your reply but I don't want additional files for my project I think analyzing the StdOutRead output will be the best for me. I only need output examples because I have no dial-up connection... Regards, Buffo Link to comment Share on other sites More sharing options...
lod3n Posted October 25, 2006 Share Posted October 25, 2006 Ohh, even better, there seems to be a registry key:msgbox(0,"Connected via RAS?",OnRas()) Func OnRas() $ras = RegRead("HKLM\System\CurrentControlSet\Services\RemoteAccess","Remote Connection") if $ras = "01000000" then return True else return False endif EndFunc [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted October 25, 2006 Share Posted October 25, 2006 (edited) @lod3nThat value is not available with a vpn connection .. in another thread of mine in which you've replied Run a Function in the Background, Function disables GUI I use the following but have a problem with a loopFunc SetConnectionCheck () $IP1 = @IPAddress1 $IP2 = @IPAddress2 $IP3 = @IPAddress3 $IP4 = @IPAddress4 If $IP2 = "0.0.0.0" Then $IPUSED = @IPAddress1 ElseIf $IP3 = "0.0.0.0" Then $IPUSED = @IPAddress2 ElseIf $IP4 = "0.0.0.0" Then $IPUSED = @IPAddress3 Else $IPUSED = @IPAddress4 EndIf TCPStartup ( ) $CHECKINGUI = "True" While 1 Sleep ( 500 ) $var = Ping($IPUSED, 500) If $var = 0 Then TraySetIcon ("off.ico") TraySetToolTip ("Connection is lost") TrayTip ("Error", "Connection is lost", 5) TrayItemSetState ($TryDisc, 128) $CHECKINGUI = "" MsgBox(16,"Connection Error", "Connection is lost", 5) Exitloop EndIf WEnd EndFunc Edited October 25, 2006 by Emiel Wieldraaijer Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Buffo Posted October 25, 2006 Author Share Posted October 25, 2006 @Emiel Wieldraaijer: Unfortunately I have no RAS connection to test your script. But it is an interesting attempt. I don't know your pob with the loop but the first impression to me is that a While...WEnd should not be used in a function. The loop should be in the main script and call the function. Your script will last in the loop if no connection is available. And I would delete the MsgBox(). It must be annoying Something like this... HotKeySet("^q", "Quit") While 1 If Not CheckConnection() Then TraySetIcon ("off.ico") TraySetToolTip ("Connection is lost") TrayTip ("Error", "Connection is lost", 5) TrayItemSetState ($TryDisc, 128) MsgBox(16,"Connection Error", "Connection is lost", 5) EndIf Sleep(1000) WEnd Func Quit() Exit EndFunc Func CheckConnection() $IP1 = @IPAddress1 $IP2 = @IPAddress2 $IP3 = @IPAddress3 $IP4 = @IPAddress4 If $IP2 = "0.0.0.0" Then $IPUSED = @IPAddress1 ElseIf $IP3 = "0.0.0.0" Then $IPUSED = @IPAddress2 ElseIf $IP4 = "0.0.0.0" Then $IPUSED = @IPAddress3 Else $IPUSED = @IPAddress4 EndIf TCPStartup ( ) $var = Ping($IPUSED, 500) TCPShutdown() Return $var EndFunc @lod3n: I tried your solution and I am wait for a reply of my test user. You wrote you are not sure if it works, if any one knows more I would be happy to know, too Is it not possible for someone to post the ipconfig /all ouput in connected and disconnected state? I think this will be the most secure way... Regards, Buffo Link to comment Share on other sites More sharing options...
lod3n Posted October 25, 2006 Share Posted October 25, 2006 Okay:#include <Constants.au3> $ipcfg = readIpConfig() if stringinstr($ipcfg,"VPN") or stringinstr($ipcfg,"PPP") Then msgbox(0,"","Connected Remotely") Else msgbox(0,"","Not Connected Remotely") EndIf func readIpConfig() $foo = Run("ipconfig /all", @SystemDir, @SW_HIDE, $STDOUT_CHILD) $output = "" While 1 $output &= StdoutRead($foo) If @error Then ExitLoop Wend consolewrite($ipcfg) return $output EndFunc Hopefully, "VPN" or "PPP" appear in the ipconfig output if they are remote. You'll have to test this. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Buffo Posted October 26, 2006 Author Share Posted October 26, 2006 @lod3n: Thx! Short summary: Every time an internet connection is accomplished "PPP" will be anywhere displayed. Every time an VPN connection is accomplished "VPN" will be in the output. It could be that the name of the ras connection would be displayed or something else, I don't know. That why I ask I will test it and give feedback Regards, Buffo Link to comment Share on other sites More sharing options...
lod3n Posted October 26, 2006 Share Posted October 26, 2006 (edited) I am connected to the Internet, but not by dialup, and "PPP" is not displayed. But, I'm still not sure that will work. But perhaps you could use the registry function to check dialup, and the ipconfig function to check VPN. That ought to work. Edited October 26, 2006 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
theswortz Posted March 16, 2007 Share Posted March 16, 2007 I use the rasdial command at the command line to see if my VPN connection is currently connected. Just type that in with no arguments. Link to comment Share on other sites More sharing options...
SadBunny Posted March 16, 2007 Share Posted March 16, 2007 (edited) @lod3n: Thx!Short summary: Every time an internet connection is accomplished "PPP" will be anywhere displayed. Every time an VPN connection is accomplished "VPN" will be in the output.It could be that the name of the ras connection would be displayed or something else, I don't know. That why I ask I will test it and give feedback Regards,BuffoDon't know if that helps but I googled a bit and came across some support forum (-=* HERE *=-) and found this: (and btw yes it mentions both VPN and RAS! )My client can VPN into the RRAS box and receives DHCP/DNS/WINS information properly from the appropriate server on the LAN. Here's the output of "ipconfig/all" from the client while connected:----------------Windows 2000 IP Configuration Host Name . . . . . . . . . . . . : feline Primary DNS Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No DNS Suffix Search List. . . . . . : example.comEthernet adapter Local Area Connection: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : NETGEAR FA310TX Fast Ethernet Adapter (NGRPCI) Physical Address. . . . . . . . . : 00-A0-CC-5D-A4-D6 DHCP Enabled. . . . . . . . . . . : No IP Address. . . . . . . . . . . . : 192.168.0.2 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.0.1 DNS Servers . . . . . . . . . . . : 192.168.0.1PPP adapter VPN via Uranus: Connection-specific DNS Suffix . : example.com Description . . . . . . . . . . . : WAN (PPP/SLIP) Interface Physical Address. . . . . . . . . : 00-53-45-00-00-00 DHCP Enabled. . . . . . . . . . . : No IP Address. . . . . . . . . . . . : 192.168.2.145 Subnet Mask . . . . . . . . . . . : 255.255.255.255 Default Gateway . . . . . . . . . : DNS Servers . . . . . . . . . . . : 192.168.2.2 192.168.2.2 192.168.3.2 Primary WINS Server . . . . . . . : 192.168.2.2 Secondary WINS Server . . . . . . : 192.168.3.2 Edited March 16, 2007 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
SadBunny Posted March 16, 2007 Share Posted March 16, 2007 Don't know if that helps but I googled a bit and came across some support forum (-=* HERE *=-) and found this: (and btw yes it mentions both VPN and RAS! )And how the hell did I miss the fact that this is a 6 months old thread! ARGH Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Buffo Posted March 16, 2007 Author Share Posted March 16, 2007 It's really a couple of months ago I asked the question and I don't need any answers any more but I want to thank you although for your help 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