ShenLong Posted December 3, 2014 Share Posted December 3, 2014 Hi EveryBody ! I want enable/disable network adapter on win 7. i have script on win xp but it not work on win 7, please help me Link to comment Share on other sites More sharing options...
computergroove Posted December 3, 2014 Share Posted December 3, 2014 Can you share the script that works on xp? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
ShenLong Posted December 3, 2014 Author Share Posted December 3, 2014 (edited) Func DisNet() $oLanConnection = "Local Area Connection"; Change this to the name of the adapter to be disabled ! $bEnable = false ; 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",BinaryToString("0x4B68C3B46E672074C3AC6D207468E1BAA57920",4)&' Card' & $strFolderName ) 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",BinaryToString("0x4B68C3B46E672074C3AC6D207468E1BAA57920",4)&' Card' & $oLanConnection) 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(3000) EndFunc Func EnaNet() $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",BinaryToString("0x4B68C3B46E672074C3AC6D207468E1BAA57920",4) & $strFolderName) 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",BinaryToString("0x4B68C3B46E672074C3AC6D207468E1BAA57920",4) & $oLanConnection ) 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(3000) EndFunc Edited December 3, 2014 by ShenLong Link to comment Share on other sites More sharing options...
Docfxit Posted December 3, 2014 Share Posted December 3, 2014 This works: #RequireAdmin ShellExecuteWait("netsh.exe", 'int set interface "Local Area Connection" disable', "", "", @SW_HIDE) ShellExecuteWait("netsh.exe", 'int set interface "Local Area Connection 2" disable', "", "", @SW_HIDE) ShellExecuteWait("netsh.exe", 'int set interface "Wireless Network Connection 4" disable', "", "", @SW_HIDE) Docfxit Link to comment Share on other sites More sharing options...
ShenLong Posted December 3, 2014 Author Share Posted December 3, 2014 o . . oh thanks Link to comment Share on other sites More sharing options...
jguinch Posted December 3, 2014 Share Posted December 3, 2014 Also you can look at my network UDF in m'y signature... Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Danyfirex Posted December 4, 2014 Share Posted December 4, 2014 look in my signature. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Gianni Posted December 4, 2014 Share Posted December 4, 2014 this >link could interest you. Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
AZJIO Posted December 4, 2014 Share Posted December 4, 2014 Here's what I have: Device_off_on .au3 ; Disable the device (network card) RunWait(@ScriptDir&'devcon disable @PCIVEN_10EC&DEV_8168*', '', @SW_HIDE) ; Enable the device (network card) RunWait(@ScriptDir&'devcon enable @PCIVEN_10EC&DEV_8168*', '', @SW_HIDE) .bat REM devcon find PCI\VEN_1002^&DEV_AA18* REM devcon classes REM devcon driverfiles =ports REM devcon find *pci-e* REM devcon driverfiles =net REM devcon enable PCI\VEN_10EC^&DEV_8168* devcon status @PCI\VEN_10EC^&DEV_8168* pause My other projects or all Link to comment Share on other sites More sharing options...
jguinch Posted December 4, 2014 Share Posted December 4, 2014 With all these posts, ShenLong should find happiness ! .... But apparently it is already done Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF 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