Jump to content

Change remote gateway


rvn
 Share

Recommended Posts

i've server-client computers with domain system. But for a reason, i must change gateway for computers. Is there any method that i can use to made it done?! Course with autoit :D

thanx for help :D

Hi,

you may be a lucky guy.

Here's a script for changing DNS Server.

I think you are clever and you can change it for your needs.

Just have a look at helpfile for the functions and in registry of windows.

Dim $aInterface [10]
$newdns = "192.168.1.1"
For $i= 1 to 10 ; Max 10 Interfaces
 $var = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces", $i)
 If @error <> 0 then ExitLoop
 $aInterface [$i] = $var
Next
For $i = 1 To UBound ($aInterface) - 1
 If $aInterface [$i] = "" Then ExitLoop
 If RegRead ("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $aInterface [$i], "NameServer") <> "" Then
  RegWrite ("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $aInterface [$i], "NameServer", "REG_SZ", $newdns)
 EndIf
Next

;-))

Stefan

Link to comment
Share on other sites

the apps done :D

here... the code i've made... thanx to 99ojo for clue :D

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\icon\Cow.ico
#AutoIt3Wrapper_Res_Comment=Beta Version!
#AutoIt3Wrapper_Res_Description=Simple tool for manage remote interface
#AutoIt3Wrapper_Res_Fileversion=1.0.0.1
#AutoIt3Wrapper_Res_LegalCopyright=@2009 Ervan B.S
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Obfuscator=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.3.0.0
    Author:         rvn/Ervan B.S
    
    Script Function:
    change_remote_gateway
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $ipTarget, $aInterface[10], $i, $var, $interfaceTarget

#Region ### START Koda GUI section ### Form=D:\ra\script\ChangeRemoteInterface.kxf
$Form1 = GUICreate("Change Remote Interface - 1.0.0.1 Beta", 263, 249, -1, -1)
$Group1 = GUICtrlCreateGroup("Computer Target", 8, 0, 249, 41)
$Input1 = GUICtrlCreateInput("", 16, 16, 121, 21)
$Button1 = GUICtrlCreateButton("Get Remote Interface", 144, 16, 105, 17, $BS_DEFPUSHBUTTON)
GUICtrlSetTip(-1, "Get remote interface")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Interface", 8, 40, 249, 41)
$Combo1 = GUICtrlCreateCombo("", 16, 56, 233, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Interface's Values", 8, 80, 249, 161)
$Label1 = GUICtrlCreateLabel("IP Address", 16, 96, 55, 17)
$Input2 = GUICtrlCreateInput("", 112, 96, 121, 21)
$Label2 = GUICtrlCreateLabel("Subnet Mask", 16, 120, 67, 17)
$Input3 = GUICtrlCreateInput("", 112, 120, 121, 21)
$Label3 = GUICtrlCreateLabel("Default Gateway", 16, 144, 83, 17)
$Input4 = GUICtrlCreateInput("", 112, 144, 121, 21)
$Label4 = GUICtrlCreateLabel("DNS", 16, 168, 27, 17)
$Input5 = GUICtrlCreateInput("", 112, 168, 121, 21)
$Button2 = GUICtrlCreateButton("Update Values", 112, 200, 121, 17, 0)
$Button3 = GUICtrlCreateButton("?", 16, 216, 17, 17, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            get_interface_()
        Case $Button2
            update_interface_()
        Case $Button3
            about_()
        Case $Combo1
            get_interface_value()
    EndSwitch
WEnd

Func get_interface_value()
    $interfaceTarget = GUICtrlRead($Combo1)
    ;MsgBox(262144,"$interfaceTarget",$interfaceTarget)
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "")
    GUICtrlSetData($Input4, "")
    GUICtrlSetData($Input5, "")
    $ip_ = RegRead("\\" & $ipTarget & "\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $interfaceTarget, "IPAddress")
    $subnet_ = RegRead("\\" & $ipTarget & "\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $interfaceTarget, "SubnetMask")
    $gateway_ = RegRead("\\" & $ipTarget & "\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $interfaceTarget, "DefaultGateway")
    $dns_ = RegRead("\\" & $ipTarget & "\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $interfaceTarget, "NameServer")
    GUICtrlSetData($Input2, $ip_)
    GUICtrlSetData($Input3, $subnet_)
    GUICtrlSetData($Input4, $gateway_)
    GUICtrlSetData($Input5, $dns_)
EndFunc   ;==>get_interface_value

Func get_interface_()
    $ipTarget = GUICtrlRead($Input1)
    ;MsgBox(262144,$ipTarget,$ipTarget)
    If $ipTarget = "" Then Return ""
    GUICtrlSetData($Combo1, "")
    For $i = 1 To 10 ; Max 10 Interfaces
        ;MsgBox(262144,$i,"")
        $var = RegEnumKey("\\" & $ipTarget & "\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces", $i)
        If @error Then
            ;MsgBox(262144,"Error","Error found when getting interface!")
            ;ExitLoop
            Return ""
        Else
            $aInterface[$i] = $var
            ;MsgBox(0,"",$aInterface [$i])
            GUICtrlSetData($Combo1, $var, $var)
        EndIf
    Next
EndFunc   ;==>get_interface_

Func update_interface_()
    If $ipTarget = "" Then Return ""
    If $interfaceTarget = "" Then Return ""
    RegWrite("\\" & $ipTarget & "\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $interfaceTarget, "IPAddress", "REG_MULTI_SZ", GUICtrlRead($Input2))
    RegWrite("\\" & $ipTarget & "\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $interfaceTarget, "SubnetMask", "REG_MULTI_SZ", GUICtrlRead($Input3))
    RegWrite("\\" & $ipTarget & "\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $interfaceTarget, "DefaultGateway", "REG_MULTI_SZ", GUICtrlRead($Input4))
    RegWrite("\\" & $ipTarget & "\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $interfaceTarget, "NameServer", "REG_MULTI_SZ", GUICtrlRead($Input5))
    MsgBox(262144, "Updated!", "Updated value to remote server... done!")
    get_interface_value()
EndFunc   ;==>update_interface_

Func about_()
    WinSetState($Form1, "", @SW_HIDE)
    MsgBox(262208, "About - Change Remote Interface - 1.0.0.1 Beta", "Change Remote Interface - 1.0.0.1 Beta" & @CRLF & "--------------------------------------------------------" & @CRLF & "Simple tool to change remote interface." & @CRLF & "Right privileges needed for full function. " & @CRLF & "@2009 Ervan B.S" & @CRLF & @CRLF)
    WinSetState($Form1, "", @SW_SHOW)
EndFunc   ;==>about_
Link to comment
Share on other sites

  • 4 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...