viperpiper Posted February 26, 2014 Share Posted February 26, 2014 (edited) I found this on another post but was wondering if this could be turned into a script that would monitor the wired lan connection for hangups and then disable and renable the lan adapter automatically. For whatever reason on my winxp pc at work at some point in the evening it hangs on it's lan connection. When I try to connect remotely I can't because of the loss of local area connection although the Icon on theh pc still shows it as connected. The only way I can fix it, is either reboot the PC or disable and renable the lan adapter (which I can't do remotely). So is there a script that would be able to do this using perhaps some of the code from below. I tried the script from another post geared towards windows 7 to "automagically" diable and restart the adapter but it didn't seem to solve my problem. Any help appreciated.......newbie to all of this by the way. expandcollapse popup; Disable and Enable a Network card using 'Shell.Application' ; ; See also: <a href='[url=http://blog.mvpcn.net/icuc88/articles/244.aspx]http://blog.mvpcn.net/icuc88/articles/244.aspx[/url]' class='bbc_url' title='External link' rel='nofollow [url=external%27]external'>http://blog.mvpcn.net/icuc88/articles/244.aspx</a>[/url] ; ; To do: Rewrite this into a UDF. Parameters: $oLanConnection and $bEnabled $oLanConnection = "Local Area Connection"; Change this to the name of the adapter to be disabled ! $bEnable = true ; Change this to 'false' to DISABLE the network adapter if @OSType<>"WIN32_NT" then Msgbox(0,"","This script requires Windows 2000 or higher.") exit endif if @OSVersion="WIN_2000" then $strFolderName = "Network and Dial-up Connections" else $strFolderName = "Network Connections"; Windows XP endif Select Case StringInStr("0409,0809,0c09,1009,1409,1809,1c09,2009,2409,2809,2c09,3009,3409", @OSLang) ; English (United States) $strEnableVerb = "En&able" $strDisableVerb = "Disa&ble" ; Add here the correct Verbs for your Operating System Language EndSelect ;Virtual folder containing icons for the Control Panel applications. (value = 3) Const $ssfCONTROLS = 3 $ShellApp = ObjCreate("Shell.Application") $oControlPanel = $shellApp.Namespace($ssfCONTROLS) ; Find 'Network connections' control panel item $oNetConnections="" For $FolderItem in $oControlPanel.Items If $FolderItem.Name = $strFolderName then $oNetConnections = $FolderItem.GetFolder Exitloop Endif Next If not IsObj($oNetConnections) Then MsgBox(0,"Error","Couldn't find " & $strFolderName & " folder." ) Exit EndIf For $FolderItem In $oNetConnections.Items If StringLower($FolderItem.Name) = StringLower($oLanConnection) Then $oLanConnection = $FolderItem Exitloop EndIf Next If not IsObj($oLanConnection) Then MsgBox(0,"Error","Couldn't find " & $oLanConnection & " Item." ) Exit EndIf $oEnableVerb="" $oDisableVerb="" For $Verb In $oLanConnection.Verbs If $Verb.Name = $strEnableVerb Then $oEnableVerb = $Verb EndIf If $Verb.Name = $strDisableVerb Then $oDisableVerb = $Verb EndIf Next If $bEnable then If IsObj($oEnableVerb) Then $oEnableVerb.DoIt ; Enable network card Endif If not $bEnable then If IsObj($oDisableVerb) Then $oDisableVerb.DoIt; Disable network card EndIf Sleep(1000) Edited February 26, 2014 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 26, 2014 Moderators Share Posted February 26, 2014 viperpiper, did you notice the announcement at the top of this forum indicating this is not a general support forum? You will get a much better response if you request that it be moved to the appropriate forum. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 26, 2014 Moderators Share Posted February 26, 2014 viperpiper,Welcome to the AutoIt forum. But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "This is NOT a general support forum!". I have moved the thread for you, but would ask you to be more careful in future. And when you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
viperpiper Posted February 26, 2014 Author Share Posted February 26, 2014 sorry guys...... I didn't RTFM..... 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