RAMzor Posted April 5, 2006 Share Posted April 5, 2006 Hello All! I will start my script after that network cable is plugged. How can i know if network cable is plugged or unplugged? Link to comment Share on other sites More sharing options...
seandisanti Posted April 5, 2006 Share Posted April 5, 2006 Hello All!I will start my script after that network cable is plugged. How can i know if network cable is plugged or unplugged?use netsh to check network connection, or you could even just run ipconfig/all>whatever.txt and go through that to check. Link to comment Share on other sites More sharing options...
Uten Posted April 5, 2006 Share Posted April 5, 2006 Do you want somthing to trigger your script or do you want to know if the network is down? From the help file: Ping ( address or hostname [, timeout] ) Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
RAMzor Posted April 6, 2006 Author Share Posted April 6, 2006 I want identify network connection to trigger my script :"> But I dont have the IP adderss and tcpip - only MAC address (Physical Address like F0-FF-FF-00-00-01).This is fiber network card from 3Com installed on Win2k (tester PC) and I want automaticaly run a test program for the connected device as I connect the divice to the PC (fiber optic network connection). Link to comment Share on other sites More sharing options...
nfwu Posted April 6, 2006 Share Posted April 6, 2006 (edited) Check out the _GetIPConfigData() UDF in my sig. #) EDIT: If the IP address is something invalid, like 0.0.0.0, the network should be down. If that network connection is the only one on the PC, ping 255.255.255.255. If you get a reply, the network is up. (This works because 255.255.255.255 is a limited broadcast address) Edited April 6, 2006 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
RAMzor Posted April 6, 2006 Author Share Posted April 6, 2006 No idea? Link to comment Share on other sites More sharing options...
seandisanti Posted April 6, 2006 Share Posted April 6, 2006 No idea? few ways to go. depending on your operating system, you can do a :ipconfig/all > ipinfo.txt then parse the file for the device with that mac idnetsh would work too, same kind of thing, google for netsh and you can get all the switches and usage details, then use it to pipe info for that connection out to a text file the same way. then you'll be able to see all of the details, as far as ip address, state (i think), etc. Link to comment Share on other sites More sharing options...
GEOSoft Posted April 7, 2006 Share Posted April 7, 2006 (edited) Here's a method I used last night for a similar problem (Thanks to Larry & Trids) $ChecK_It = IsAlive() If StringInStr($ChecK_It, "Not Connected") OR StringInStr($ChecK_It, "OffLine") Then Whatever routine you want to use EndIf Func Is_Alive() Ping('www.google.com',3000) $Internet_Connection_Modem = 0x1 $Internet_Connection_Lan = 0x2 $Internet_Connection_Proxy = 0x4 $Internet_Connection_Modem_Busy = 0x8 $Internet_Ras_Installed = 0x10 $Internet_Connection_Offline = 0x20 $Internet_Connection_Configured = 0x40 $Ret = DllCall ("WinInet.dll", "int", "InternetGetConnectedState", "int_ptr", 0, "int", 0) If $Ret[0] then ;check type of connection $Sx = "" If BitAND ($Ret[1], $Internet_Connection_Modem) Then $Sx = $Sx & "MODEM" & @LF If BitAND ($Ret[1], $Internet_Connection_Lan) Then $Sx = $Sx & "LAN" & @LF If BitAND ($Ret[1], $Internet_Connection_Proxy) Then $Sx = $Sx & "PROXY" & @LF If BitAND ($Ret[1], $Internet_Connection_Modem_Busy) Then $Sx = $Sx & "MODEM_BUSY" & @LF If BitAND ($Ret[1], $Internet_Ras_Installed) Then $Sx = $Sx & "RAS_INSTALLED" & @LF If BitAND ($Ret[1], $Internet_Connection_Offline) Then $Sx = $Sx & "OFFLINE" & @LF If BitAND ($Ret[1], $Internet_Connection_Configured) Then $Sx = $Sx & "CONFIGURED" & @LF Else $Sx = "Not Connected" Endif Return $Sx EndFunc ;<==> Is_Alive() The Ping was added only because my wireless likes to go to sleep every now and then so running the ping (even if it doesn't resolve) gets the wireless kick started so that the rest of the check is accurate. The ping alone won't really tell me if I'm connected or not. The rest of the Func does. *** EDITED because I started the code at the wrong point Edited April 7, 2006 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
nfwu Posted April 8, 2006 Share Posted April 8, 2006 C:\Documents and Settings\Owner>ipconfig /all Windows IP Configuration Host Name . . . . . . . . . . . . : fake_host_name Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Mixed IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No Ethernet adapter Local Area Connection: Media State . . . . . . . . . . . : Media disconnected Description . . . . . . . . . . . : Realtek RTL8139/810x Family Fast Eth ernet NIC Physical Address. . . . . . . . . : FF-FF-FF-FF-FF-FF C:\Documents and Settings\Owner>ipconfig Windows IP Configuration Ethernet adapter Local Area Connection: Media State . . . . . . . . . . . : Media disconnected C:\Documents and Settings\Owner> Shows that ipconfig prints "Media disconnected" when the cable is unplugged. NOTE: Host name and Physical Addresses have been removed. (FF-FF-FF-FF-FF-FF is the physical address for a limited broadcast) #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() 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