SandelPerieanu Posted June 2, 2006 Share Posted June 2, 2006 (edited) expandcollapse popup$ret = LanToggle('Local Area Connection') Select Case $ret = 1 MsgBox(0, '', 'Done!') Case Else MsgBox(0, '', '"Lan Area Connection" is not available') EndSelect Func LanToggle($lanconnection) $status = '' $status_ = '' $objwmiservice = ObjGet ('winmgmts:\\localhost\root\CIMV2') $colitems = $objWMIService.ExecQuery ('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x10 + 0x20) If IsObj ($colitems) Then For $objitem In $colitems If String($objitem.netconnectionid) = $lanconnection Then $status = Not (Not ($objitem.netconnectionstatus)) ExitLoop EndIf Next EndIf $shellapp = ObjCreate ('shell.application') $ocontrolpanel = $shellApp.Namespace (3) For $folderitem In $ocontrolpanel.items If $folderitem.name = 'Network Connections' Then For $folderitem In $folderitem.getfolder.items If StringLower($folderitem.name) = StringLower($lanconnection) Then For $verb in $folderitem.verbs If $verb.name = 'En&able' Or $verb.name = 'Disa&ble' Then $verb.doit $exitlantoggle = 0 While $exitlantoggle = 0 Sleep(1) $colitems = $objWMIService.ExecQuery ('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x10 + 0x20) If IsObj ($colitems) Then For $objitem In $colitems If String($objitem.netconnectionid) = $lanconnection Then $status_ = Not (Not ($objitem.netconnectionstatus)) EndIf If $status = Not ($status_) Then $exitlantoggle = 1 ExitLoop EndIf Next EndIf WEnd Return 1 EndIf Next EndIf Next EndIf Next Return 0 EndFunc ;==>LanToggle Edited June 2, 2006 by psandu.ro Link to comment Share on other sites More sharing options...
nfwu Posted June 2, 2006 Share Posted June 2, 2006 People would like code to be placed in a code box: expandcollapse popup$ret = LanToggle('Local Area Connection') Select Case $ret = 1 MsgBox(0, '', 'Done!') Case Else MsgBox(0, '', '"Lan Area Connection" is not available') EndSelect Func LanToggle($lanconnection) $status = '' $status_ = '' $objwmiservice = ObjGet ('winmgmts:\\localhost\root\CIMV2') $colitems = $objWMIService.ExecQuery ('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x10 + 0x20) If IsObj ($colitems) Then For $objitem In $colitems If String($objitem.netconnectionid) = $lanconnection Then $status = Not (Not ($objitem.netconnectionstatus)) ExitLoop EndIf Next EndIf $shellapp = ObjCreate ('shell.application') $ocontrolpanel = $shellApp.Namespace (3) For $folderitem In $ocontrolpanel.items If $folderitem.name = 'Network Connections' Then For $folderitem In $folderitem.getfolder.items If StringLower($folderitem.name) = StringLower($lanconnection) Then For $verb in $folderitem.verbs If $verb.name = 'En&able' Or $verb.name = 'Disa&ble' Then $verb.doit $exitlantoggle = 0 While $exitlantoggle = 0 Sleep(1) $colitems = $objWMIService.ExecQuery ('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x10 + 0x20) If IsObj ($colitems) Then For $objitem In $colitems If String($objitem.netconnectionid) = $lanconnection Then $status_ = Not (Not ($objitem.netconnectionstatus)) If $status = Not ($status_) Then $exitlantoggle = 1 ExitLoop EndIf Next EndIf WEnd Return 1 EndIf Next EndIf Next EndIf Next Return 0 EndFunc ;==>LanToggle Use the tags: #) 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