commit 76f090ec3a9a80c6386cfbf8ca8f5e7e87e041d4 Author: Bernhard Date: Tue Sep 12 23:18:47 2017 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..751553b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.bak diff --git a/ChangeDNSServer.au3 b/ChangeDNSServer.au3 new file mode 100644 index 0000000..680cf04 --- /dev/null +++ b/ChangeDNSServer.au3 @@ -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 \ No newline at end of file diff --git a/ChangeDNSServer.exe b/ChangeDNSServer.exe new file mode 100644 index 0000000..d1ec385 Binary files /dev/null and b/ChangeDNSServer.exe differ diff --git a/ChangeDNSServer2.au3 b/ChangeDNSServer2.au3 new file mode 100644 index 0000000..1d789d9 --- /dev/null +++ b/ChangeDNSServer2.au3 @@ -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) + diff --git a/ChangeDNSServer2.exe b/ChangeDNSServer2.exe new file mode 100644 index 0000000..1072029 Binary files /dev/null and b/ChangeDNSServer2.exe differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/starter.au3 b/starter.au3 new file mode 100644 index 0000000..d9f92bb --- /dev/null +++ b/starter.au3 @@ -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") diff --git a/starter.exe b/starter.exe new file mode 100644 index 0000000..af52cd6 Binary files /dev/null and b/starter.exe differ