Sign in to follow this  
Followers 0
ShenLong

Enable/Disable Network Adapter on Windows 7

10 posts in this topic

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 :D

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

:D 

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 by ShenLong

Share this post


Link to post
Share on other sites

o . . oh :D thanks  

Share this post


Link to post
Share on other sites

look in my signature.

Saludos


 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

this >link could interest you.


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0