first commit
This commit is contained in:
commit
76f090ec3a
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.bak
|
64
ChangeDNSServer.au3
Normal file
64
ChangeDNSServer.au3
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
|
||||||
|
#AutoIt3Wrapper_UseUpx=n
|
||||||
|
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
|
||||||
|
Global $lokaleIP
|
||||||
|
Global $NeuerDNS1 = "192.168.1.15"
|
||||||
|
Global $NeuerDNS2 = "192.168.1.16"
|
||||||
|
|
||||||
|
$lokaleIP = @IPAddress1
|
||||||
|
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '@IPAddress1' & @lf & @lf & 'Return:' & @lf & @IPAddress1) ;### Debug MSGBOX
|
||||||
|
|
||||||
|
If @IPAddress1 <> "0.0.0.0" Then
|
||||||
|
_Set_DNS(@IPAddress1, $NeuerDNS1, $NeuerDNS2)
|
||||||
|
MsgBox(0,"","Fehlercode: " & @error)
|
||||||
|
EndIf
|
||||||
|
If @IPAddress2 <> "0.0.0.0" Then
|
||||||
|
_Set_DNS(@IPAddress2, $NeuerDNS1, $NeuerDNS2)
|
||||||
|
EndIf
|
||||||
|
If @IPAddress2 <> "0.0.0.0" Then
|
||||||
|
_Set_DNS(@IPAddress2, $NeuerDNS1, $NeuerDNS2)
|
||||||
|
EndIf
|
||||||
|
If @IPAddress2 <> "0.0.0.0" Then
|
||||||
|
_Set_DNS(@IPAddress2, $NeuerDNS1, $NeuerDNS2)
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
Exit 0
|
||||||
|
|
||||||
|
|
||||||
|
;===============================================================================
|
||||||
|
; Function Name: _Set_DNS($Card_IP, $DNS_1=-1, $DNS_2=-1, $strComputer = ".")
|
||||||
|
; Description:: Eine od. beide DNS-Adressen für Netzwerkadapter mit übergebener IP setzen
|
||||||
|
; Parameter(s): $Card_IP IP des Netzwerkadapters
|
||||||
|
; $DNS_1 IP für DNS1 (-1 Adresse wird nicht gesetzt)
|
||||||
|
; $DNS_2 IP für DNS2 (-1 Adresse wird nicht gesetzt)
|
||||||
|
; $strComputer "." - der lokale PC
|
||||||
|
; Return Value(s): Erfolg Array mit [DNS1,DNS2]
|
||||||
|
; Fehler 0 @error 1 - keine DNS_IP übergeben
|
||||||
|
; @error 2 - Adapter_IP existiert nicht
|
||||||
|
; Author(s): BugFix (bugfix@autoit.de)
|
||||||
|
;===============================================================================
|
||||||
|
Func _Set_DNS($Card_IP, $DNS_1=-1, $DNS_2=-1, $strComputer = ".")
|
||||||
|
If ($DNS_1 = -1) And ($DNS_2 = -1) Then Return SetError(1,0,0)
|
||||||
|
Local $objWMIService = ObjGet("winmgmts:" _
|
||||||
|
& "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
|
||||||
|
Local $colNetCards = $objWMIService.ExecQuery _
|
||||||
|
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
|
||||||
|
For $objNetCard In $colNetCards
|
||||||
|
|
||||||
|
MsgBox(0,"","hier: " & $objNetCard.IPAddress(0))
|
||||||
|
|
||||||
|
|
||||||
|
If $objNetCard.IPAddress(0) = $Card_IP Then
|
||||||
|
;MsgBox(0,"","dns")
|
||||||
|
If $DNS_1 <> -1 Then
|
||||||
|
$objNetCard.DNSServerSearchOrder(0) = $DNS_1
|
||||||
|
EndIf
|
||||||
|
If $DNS_2 <> -1 Then
|
||||||
|
$objNetCard.DNSServerSearchOrder(1) = $DNS_2
|
||||||
|
EndIf
|
||||||
|
Local $aReturn[2] = [$objNetCard.DNSServerSearchOrder(0), $objNetCard.DNSServerSearchOrder(1)]
|
||||||
|
Return $aReturn
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
Return SetError(2,0,0)
|
||||||
|
EndFunc ;==>_Set_DNS
|
BIN
ChangeDNSServer.exe
Normal file
BIN
ChangeDNSServer.exe
Normal file
Binary file not shown.
21
ChangeDNSServer2.au3
Normal file
21
ChangeDNSServer2.au3
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#RequireAdmin
|
||||||
|
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
|
||||||
|
#AutoIt3Wrapper_UseUpx=n
|
||||||
|
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
|
||||||
|
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip delete dns name="LAN-Verbindung" all',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung" addr=192.168.1.15 index=1',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung" addr=192.168.1.16 index=2',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip delete dns name="LAN-Verbindung 2" all',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung 2" addr=192.168.1.15 index=1',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung 2" addr=192.168.1.16 index=2',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip delete dns name="LAN-Verbindung 3" all',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung 3" addr=192.168.1.15 index=1',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung 3" addr=192.168.1.16 index=2',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip delete dns name="LAN-Verbindung 4" all',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung 4" addr=192.168.1.15 index=1',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung 4" addr=192.168.1.16 index=2',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip delete dns name="LAN-Verbindung 5" all',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung 5" addr=192.168.1.15 index=1',"",@SW_SHOW)
|
||||||
|
RunAsWait("Administrator", "KAN001", "JOH13k35", 0, 'netsh interface ip add dns name="LAN-Verbindung 5" addr=192.168.1.16 index=2',"",@SW_SHOW)
|
||||||
|
|
BIN
ChangeDNSServer2.exe
Normal file
BIN
ChangeDNSServer2.exe
Normal file
Binary file not shown.
4
starter.au3
Normal file
4
starter.au3
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
|
||||||
|
#AutoIt3Wrapper_UseUpx=n
|
||||||
|
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
|
||||||
|
RunAs("administrator", "KAN001", "JOH13k35", 0, @ScriptDir & "\ChangeDNSServer2.exe")
|
BIN
starter.exe
Normal file
BIN
starter.exe
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user