Beiträge von FISO
-
-
Hallo FISO,
für welche Anwendungsart braucht man denn so etwas. SpassVirus
mfg (Auto)Bert
Für mac changer!
Funktionen einfach zu übernehmen macht wenig Sinn.
Man sollte schon einen Blick hineinwerfen.
In der Funktion _NICContol()
wird $strFolderName in Abhängigkeit zur Systemsprache gesetzt.
Es wird aber nur EN und FR abgeprüft. Für dein System bleibt demzufolge
die Variable einfach leer.Hast recht geb mein bestes das ganze zu lernen ist für mich als anfänger nicht leicht!
meinst du eine systemabfrage würde da helfen?! -
Hi
Leute suche eine lösung die netzwerkkarten von jederman zu deactiviern und wieder zuactivieren egal was für beribssystem oder bit!
habe in diversen foren durchsucht probiert und nicht hinbekomen!
bei den meisten muss man ne id von netzwerkkarten(Devcon) eingeben !
das geht ja bei mir nicht weill ich will das der script bei jedem funktioniert und jeder hat ne andere id bzw. Betriebssystem (32,64bit).
das habe ich von einem anderen autoit forum!:Spoiler anzeigen
[autoit];====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name : _NicControl
; Description : Activate or deactivate a Network Interface Controler (NIC)
; Syntax : _NicControl($oLanConnection, [$iFlag, , [$iFullName]])
; Parameter(s) : $oLanConnection - The name of the Lan connection.
; If equal to 'All' then change state of all NIC.
; $iFlag - The state of the NIC (Default 1 for activate).
; $iFullName - Look for string $oLanConnection in NIC name (Default 1 for full name).
; Requirement(s) : Win32_NT OS
; Return value(s) : On Success - Return 1
; On Failure - Return 0 and @Extented is set.
; @Extented = 1 : Not Win32_NT OS
; @Extented = 2 : Network folder not find.
; @Extented = 3 : Lan connection not find.
; Author : Tlem <tlem at tuxolem dot net>
; http://www.autoitscript.fr/forum/viewtopic.php?f=21&t=1092
; Note(s) :
;
; To Do : Get individual errors for changing state of multiple NIC (Perhaps with array).
; ===================================================================================================================#RequireAdmin
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
Global $strEnableVerb
Global $strDisableVerb
Global $strFolderName; ===================================================================================================================
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
; ===================================================================================================================
; Exemple :
; $Res = _NICContol('all', 1, 0)
; MsgBox(0, "", "$Res=" & $Res & " @Error=" & @error & " @extented=" & @extended)
; ===================================================================================================================
; ===================================================================================================================Func _NICContol($oLanConnection, $iFlag = 1, $iFullName = 1)
[/autoit] [autoit][/autoit] [autoit]
; Control OS type.
If @OSTYPE <> "WIN32_NT" Then
SetError(1, 1)
Return 0
EndIf; Langage selection.
[/autoit] [autoit][/autoit] [autoit]
Select
; English (United States)
Case StringInStr("0409,0809,0c09,1009,1409,1809,1c09,2009,2409,2809,2c09,3009,3409", @OSLang)
$strEnableVerb = "En&able"
$strDisableVerb = "Disa&ble"
If @OSVersion = "WIN_2000" Then
$strFolderName = "Network and Dial-up Connections" ; Windows 2000
Else
$strFolderName = "Network Connections"; Windows XP
EndIf; Français (France)
[/autoit] [autoit][/autoit] [autoit]
Case StringInStr("040c,080c,0c0c,100c,140c,180c", @OSLang)
$strEnableVerb = "&Activer"
$strDisableVerb = "&Désactiver"
If @OSVersion = "WIN_2000" Then
$strFolderName = "Connexions réseau et accès à distance" ; Windows 2000
Else
$strFolderName = "Connexions réseau"; Windows XP
EndIf; Add here the correct Verbs for your Operating System Language
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
EndSelect; Vista/W2K8
[/autoit] [autoit][/autoit] [autoit]
If @OSVersion <> "WIN_2000" And @OSVersion <> "WIN_XP" And @OSVersion <> "WIN_2003" Then
$Res = _NICContolWin32New($oLanConnection, $iFlag, $iFullName)
Else
; W2K/XP/W2K3
$Res = _NICContolWin32($oLanConnection, $iFlag, $iFullName)
EndIf
SetError(@error, @extended)
Return $ResEndFunc ;==>_NICContol
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _NICContolWin32($oLanConnection, $iFlag = 1, $iFullName = 1)
[/autoit] [autoit][/autoit] [autoit]
; Inspired from :
; Original author : SvenP
; http://www.autoitscript.com/forum/index.ph…indpost&p=87000
$ShellApp = ObjCreate("Shell.Application")
$oControlPanel = $ShellApp.Namespace(3); Find 'Network connections' control panel item
[/autoit] [autoit][/autoit] [autoit]
$oNetConnections = ""
For $FolderItem In $oControlPanel.Items
If $FolderItem.Name = $strFolderName Then
$oNetConnections = $FolderItem.GetFolder
ExitLoop
EndIf
Next; If no 'Network connections' folder then return error.
[/autoit] [autoit][/autoit] [autoit]
If Not IsObj($oNetConnections) Then
SetError(1, 2)
Return 0
EndIf; Change all NIC state (Do not return extented errors).
[/autoit] [autoit][/autoit] [autoit]
If StringLower($oLanConnection) = "all" Then
For $FolderItem In $oNetConnections.Items
_NICContolWin32($FolderItem.name, $iFlag)
Next
Return 1
EndIf; Change NIC state by partial name (Do not return extented errors).
[/autoit] [autoit][/autoit] [autoit]
If $iFullName = 0 Then
For $FolderItem In $oNetConnections.Items
If StringInStr(StringLower($FolderItem.name), StringLower($oLanConnection)) Then
_NICContolWin32($FolderItem, $iFlag)
EndIf
Next
Return 1
EndIf; Find the collection of the network connection name.
[/autoit] [autoit][/autoit] [autoit]
For $FolderItem In $oNetConnections.Items
If StringLower($FolderItem.Name) = StringLower($oLanConnection) Then
$oLanConnection = $FolderItem
ExitLoop
EndIf
Next; If no network connection name then return error.
[/autoit] [autoit][/autoit] [autoit]
If Not IsObj($oLanConnection) Then
SetError(1, 3)
Return 0
EndIf$oEnableVerb = ""
[/autoit] [autoit][/autoit] [autoit]
$oDisableVerb = ""; Find the state of the network connection.
[/autoit] [autoit][/autoit] [autoit]
For $Verb In $oLanConnection.Verbs
If $Verb.Name = $strEnableVerb Then
$oEnableVerb = $Verb
$State = 0
EndIf
If $Verb.Name = $strDisableVerb Then
$oDisableVerb = $Verb
$State = 1
EndIf
Next
If $iFlag = 3 Then Return $State; Enable NIC
[/autoit] [autoit][/autoit] [autoit]
If $iFlag Then
If IsObj($oEnableVerb) Then $oEnableVerb.DoIt
EndIf; Disable NIC
[/autoit] [autoit][/autoit] [autoit]
If Not $iFlag Then
If IsObj($oDisableVerb) Then $oDisableVerb.DoIt
EndIf$begin = TimerInit()
[/autoit] [autoit][/autoit] [autoit]
While 1
$dif = Int(TimerDiff($begin) / 1000)
If $dif > 10 Then ExitLoop
; Control the state of the NIC to exit before the end of waiting time.
If $iFlag = 1 And _NICContolWin32($oLanConnection, 3) = 1 Then ExitLoop
If $iFlag = 0 And _NICContolWin32($oLanConnection, 3) = 0 Then ExitLoop
Sleep(100)
WEnd; Set the return value of the function.
[/autoit] [autoit][/autoit] [autoit]
$Res = _NICContolWin32($oLanConnection, 3)
If $iFlag = 1 And $Res = 0 Then
Return 0
ElseIf $iFlag = 0 And $Res = 1 Then
Return 0
Else
Return 1
EndIfEndFunc ;==>_NICContolWin32
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _NICContolWin32New($oLanConnection, $iFlag = 1, $iFullName = 1)
[/autoit] [autoit][/autoit] [autoit]
; Inspired from :
; Original author : Danny35d
; http://www.autoitscript.com/forum/index.ph…ndpost&p=528862
$objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", 0x30)
If IsObj($colItems) Then
$iModState = 0
[/autoit] [autoit][/autoit] [autoit]
; Activate All NIC (Return just 1 if function end correctly).
If StringLower($oLanConnection) = "all" Then
For $objItem In $colItems
If $objItem.NetConnectionID <> '' Then
_NICContolWin32New($objItem.NetConnectionID, $iFlag)
EndIf
Next
Return 1
EndIf
; Change NIC state by partial name (Return just 1 if function end correctly or if no connection was find).
If $iFullName = 0 Then
For $objItem In $colItems
If StringInStr(StringLower($objItem.NetConnectionID), StringLower($oLanConnection)) Then
$iModState = 1
$Res = _NICContolWin32New($objItem.NetConnectionID, $iFlag)
EndIf
Next
; If no connection find.
If $iModState = 0 Then
SetError(1,3)
Return 0
Else
Return 1
EndIf
EndIf; Change NIC state of $oLanConnection
[/autoit] [autoit][/autoit] [autoit]
For $objItem In $colItems
If $objItem.NetConnectionID = $oLanConnection Then
; Check State.
If $iFlag = 3 Then
If $objItem.NetEnabled = True Then
Return 1
Else
Return 0
EndIf
Else
; Change State.
If $iFlag = 0 And $objItem.NetEnabled = True Then
$objItem.Disable
ElseIf $iFlag = 1 And $objItem.NetEnabled = False Then
$objItem.Enable
EndIf
$iModState = 1
EndIf
ExitLoop
EndIf
Next
; If no connection then error.
If $iModState = 0 Then
SetError(1, 3)
Return 0
EndIf
Else
SetError(1, 2)
Return 0
EndIfIf $iFlag = 3 Then
[/autoit] [autoit][/autoit] [autoit]
While $iFlag <> _NICContolWin32New($oLanConnection, 3)
Sleep(250)
WEnd
Else
Sleep(1000)
If $iFlag = 1 And _NICContolWin32New($oLanConnection, 3) = 1 Then
Return 1
ElseIf $iFlag = 0 And _NICContolWin32New($oLanConnection, 3) = 0 Then
Return 1
Else
Return 0
EndIf
EndIfEndFunc ;==>_NICContolWin32New
[/autoit]bin jeder hilfe dankbar!
mfg
FISO -
hier ein tool von us autoit seite hier kan man angeblich universel netzwerkkarte deactivieren und activieren!
funktioniert aber bei mir nicht!?Spoiler anzeigen
[autoit]#NoTrayIcon
[/autoit] [autoit][/autoit] [autoit]
#RequireAdmin#include <GUIConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit]Global $OSver = @OSVersion
[/autoit] [autoit][/autoit] [autoit]
Global $strEnable = "En&able"
Global $strDisable = "Disa&ble"
Global $colNetwork = ""Dim $NicsFound[1][1]
[/autoit] [autoit][/autoit] [autoit]
Dim $IconFile[2]If $OSver = "WIN_VISTA" Then
[/autoit] [autoit][/autoit] [autoit]
$IconFile[0] = 'netcenter.dll'
$IconFile[1] = 8
Else
$IconFile[0] = 'shell32.dll'
$IconFile[1] = 19
EndIfMain()
[/autoit] [autoit][/autoit] [autoit]Func Main()
[/autoit] [autoit][/autoit] [autoit]
;starts the creation of the gui
Global $hGUI = GUICreate("MAC Address Changer", 320, 190)
GUISetIcon($IconFile[0], $IconFile[1])
$helpmenu = GUICtrlCreateMenu("Help")
$aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)
$exititem = GUICtrlCreateMenuItem("Exit", $helpmenu)If @OSType <> "WIN32_NT" Then
[/autoit] [autoit][/autoit] [autoit]
Msgbox(0,"Error","This script requires Windows 2000 or higher.",0,$hGUI)
Exit
EndIfIf IsAdmin() = 0 Then
[/autoit] [autoit][/autoit] [autoit]
Msgbox(0,"Error","This script requires Administrative priviledges.",0,$hGUI)
Exit
EndIf_GetNetConNames(_NetConsFolderObject())
[/autoit] [autoit][/autoit] [autoit];If the user has more that 10 pshyical devices I don't even want to handle that
[/autoit] [autoit][/autoit] [autoit]
If UBound($NicsFound, 1) - 1 > 10 Then
MsgBox (0,"Error", "Too many Devices Find a New Program",0,$hGUI)
Exit
EndIf$WinLocation = WinGetPOS($hGUI)
[/autoit] [autoit][/autoit] [autoit]
WinMove($hGUI, "", $WinLocation[0], $WinLocation[1], 320, UBound($NicsFound,1) * 30 + 190, 1)$i2 = 10
[/autoit] [autoit][/autoit] [autoit]
Dim $radio[UBound($NicsFound, 1)]
For $i = 0 To UBound($NicsFound, 1) - 1
$radio[$i] = GUICtrlCreateRadio($i + 1 & ". " & $NicsFound[$i][0], 10, $i2)
$i2 += 30
NextGUICtrlCreateLabel("Enter new MAC Address for adapter in HEX. Example: 010203040506", 10, $i2 + 20, 250, 30)
[/autoit] [autoit][/autoit] [autoit]
$newMAC = GUICtrlCreateInput("", 10, $i2 + 50, 150, 20)
GUICtrlSetBkColor(-1, 0xC0DCC0)
$toggle = GUICtrlCreateCheckbox("", 10, $i2 + 80, 15, 15)
GUICtrlSetState($toggle, $GUI_CHECKED)
GUICtrlCreateLabel("Auto Disable/Enable NIC", 30, $i2 + 80, 150, 30)
$ok = GUICtrlCreateButton("OK", 10, $i2 + 100, 75, 25)
$revertOld = GUICtrlCreateButton("Remove", 100, $i2 + 100, 75, 25)
GUISetState(@SW_SHOW);infinite loop to get user input on the GUI
[/autoit] [autoit][/autoit] [autoit]
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $aboutitem
MsgBox(0, "About", "Written By Andrew W to spoof the MAC Addresses" & @CRLF & @CRLF & _
"If you have already put in an address and you want to revert back to your original" & _
" then just use the remove button.",0,$hGUI)
Case $msg = $exititem
Exit
Case $msg = $ok
$ok = 1 ;determiner to see if the ok button was actually pressed
ExitLoop
Case $msg = $revertOld
$revertOld = 1 ;determiner to see if the ok button was actually pressed
ExitLoop
EndSelect;used to display mac for whatever radio button is currently selected
[/autoit] [autoit][/autoit] [autoit]
For $i = 0 to UBound ($NicsFound, 1) - 1
If $msg = $radio[$i] And BitAND(GUICtrlRead($radio[$i]), $GUI_CHECKED) = $GUI_CHECKED Then
$label = GUICtrlCreateLabel("Current MAC for this device is: " & $NicsFound[$i][1], 10, $i2, 250, 15)
$index = $i
EndIF
Next
WEnd;error checking making sure a adapter was selected if ok button is pressed
[/autoit] [autoit][/autoit] [autoit]
$selection = 0
If $ok = 1 Then
For $i = 0 to UBound ($NicsFound, 1) - 1
If BitAND(GUICtrlRead($radio[$i]), $GUI_CHECKED) = $GUI_CHECKED Then $selection = 1
Next;output to tell the user whats up
[/autoit] [autoit][/autoit] [autoit]
If $selection = 0 Then
MsgBox (0,"Error", "No Adapter Selected",0,$hGUI)
GUIDelete($hGUI)
Main()
EndIf$newMAC = GUICtrlRead($newMAC)
[/autoit] [autoit][/autoit] [autoit]If $newMAC = "" Then
[/autoit] [autoit][/autoit] [autoit]
MsgBox (0,"Error", "You did not enter a MAC Address",0,$hGUI)
GUIDelete($hGUI)
Main()
EndIfStringUpper($newMAC)
[/autoit] [autoit][/autoit] [autoit]If StringLen($newMAC) <> 12 OR StringIsXDigit($newMAC) = 0 Then
[/autoit] [autoit][/autoit] [autoit]
MsgBox (0,"Error", "You Entered an Invalid Address",0,$hGUI)
GUIDelete($hGUI)
Main()
Endif
Endif;get the registry keys in order to change the MAC
[/autoit] [autoit][/autoit] [autoit]
While StringLen ($index) <> 4
Select
Case StringLen ($NicsFound[$index][2]) = 1
$newindex = "000" & $NicsFound[$index][2]
ExitLoop
Case StringLen ($NicsFound[$index][2]) = 2
$newindex = "00" & $NicsFound[$index][2]
ExitLoop
Case StringLen ($NicsFound[$index][2]) = 3
$newindex = "0" & $NicsFound[$index][2]
ExitLoop
EndSelect
WEnd;does the actual registry editing
[/autoit] [autoit][/autoit] [autoit]
$registry = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & $newindex
If $revertOld = 1 Then
RegDelete($registry, "NetworkAddress")
Else
$test = RegWrite ($registry, "NetworkAddress", "REG_SZ", $newMac)
EndIfIf GUICtrlRead($toggle) = $GUI_CHECKED And $NicsFound[$index][4] <> 0 Then
[/autoit] [autoit][/autoit] [autoit]
GUISetState(@SW_DISABLE)
ProgressOn("Progress", "Please Wait...", "", Default, Default, 18)
_NicToggle($NicsFound[$index][3], 0)
ProgressSet(50)
_NicToggle($NicsFound[$index][3], 1)
ProgressSet(100, "Operation Complete")
sleep(5000)
ProgressOff()
Else
MsgBox(0, "Remember", "You must shutdown or disable and re-enable your NIC for your MAC change to take affect",0,$hGUI)
EndIfGUIDelete($hGUI)
[/autoit] [autoit][/autoit] [autoit]
Main()
EndFunc; Find the folder containing the network connection objects
[/autoit] [autoit][/autoit] [autoit]
; ==============================================================================================
Func _NetConsFolderObject()
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colNetwork = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
Return $colNetwork
EndFunc ;==>_NetConsFolderObject; Find the network connection objects
[/autoit] [autoit][/autoit] [autoit]
; ==============================================================================================
Func _GetNetConNames($colNetwork)
Dim $strNetworks, $IDXname=0, $IDXstatus=0
If IsObj($colNetwork) Then
For $clsConn In $colNetworkIf $clsConn.NetConnectionID <> '' AND $clsConn.MACAddress <> '' AND NOT StringInStr($clsConn.NetConnectionID, 'virtual') _
[/autoit] [autoit][/autoit] [autoit]
AND NOT StringInStr($clsConn.Name, 'virtual') Then ;attempt to get rid of virtual network adapters
;$strNetworks &= $clsConn.NetConnectionID & '|'
ReDim $NicsFound[$IDXname+1][5]
$NicsFound[$IDXname][0] = $clsConn.Name
$NicsFound[$IDXname][1] = $clsConn.MACAddress
$NicsFound[$IDXname][2] = $clsConn.index
$NicsFound[$IDXname][3] = $clsConn.NetConnectionID
$NicsFound[$IDXname][4] = $clsConn.NetConnectionStatus
$IDXname = $IDXname + 1
EndIf
Next
Else
MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_NetworkAdapter",0,$hGUI)
EndIf
Return
EndFunc ;==>GetNetworkNames; Disable and Enable a Network card
[/autoit]
; ==============================================================================================
; _NicToggle('local area connection', [0=disable, 1=enable])
Func _NicToggle($name, $iFlag)
If $OSver = "WIN_VISTA" OR $Osver = "WIN_2008" Then
_NetConsFolderObject()
If IsObj($colNetwork) Then
For $clsConn In $colNetwork
If $clsConn.NetConnectionID = $name Then
If $iFlag = 0 And $clsConn.NetConnectionStatus <> 0 Then
$clsConn.Disable
EndIf
If $iFlag = 1 And $clsConn.NetConnectionStatus = 0 Then
$clsConn.Enable
EndIf
ExitLoop
EndIf
Next
Else
MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_NetworkAdapter",0,$hGUI)
EndIf
Else ; Windows 2000 & XP
$objShell = ObjCreate("Shell.Application")
$strNetConn = "Network Connections"
$objCP = $objShell.Namespace(3)
For $clsConn In $objCP.Items
If $clsConn.Name = $strNetConn Then
$colNetwork = $clsConn.GetFolder
EndIf
Next
For $clsConn In $colNetwork.Items
If $clsConn.Name = $name Then
For $clsVerb In $clsConn.verbs
If $iFlag = 0 And $clsVerb.name = $strDisable Then
$clsVerb.DoIt
Sleep(5000)
Return
EndIf
If $iFlag = 1 And $clsVerb.name = $strEnable Then
$clsVerb.DoIt
Sleep(5000)
Return
EndIf
Next
EndIf
Next
EndIf
EndFunc ;==>_NicToggle -
Die Netzwerkkarte könnt ihr über das MS-Tool devcon neustarten
da muss man aber jedesmal die jeweilige netzwerkkarten id eingeben!
Eine universelle lösung wäre noch besser!
eine die bei jedem funktioniert! -
geil
funktioniert das auch mit anderen foren? -
geiles tool!
Aber:
-Schade das man kein random durchführen kan bzw kein auswahlmöglichkeit der netzwerkkarte vorhanden ist!
-Wiso muss man jedesmal pc neustarten!
-Kan man nicht einfach die netzwerkkarten deactivieren und activieren lasen mit dem tool!
Trotzdem respect ! -
geil danke!