Re: question on box
"valery_vi" <[email protected]> Sun, 02 Sep 2007 11:21:01 -0000
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
There is IPSet (2005) script here (not tested):
http://techidiots.net/autoit-scripts/ipset.rar/view
;--------------------------------------------------------
;AutoIt Version: 3.1.1.91 Beta
;
;Script Author: Andrew Calcutt
;Script Date: 12/05/2005
;Script Name: IPSet
;Script Function: Set IP address of a specific connection
;--------------------------------------------------------
#Include <process.au3>
#include <GuiConstants.au3>
$tempfile = "C:\IPSet_Temp.txt"
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS =
0x04000000
GUICreate("IP_Setttings", 259, 327, (@DesktopWidth - 259) / 2,
(@DesktopHeight - 327) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE +
$WS_CLIPSIBLINGS)
;GUISetIcon ("network.ico")
$connections = GUICtrlCreateCombo("Pick Connection", 20, 10, 220, 21)
GUICtrlCreateGroup("IP Settings", 10, 40, 240, 130)
$dhcp = GUICtrlCreateRadio("DHCP", 20, 60, 220, 20)
$static = GUICtrlCreateRadio("Specify IP", 20, 80, 230, 20)
GUICtrlCreateLabel("IP", 20, 100, 60, 20)
GUICtrlCreateLabel("Subnet", 20, 120, 70, 20)
GUICtrlCreateLabel("Gateway", 20, 140, 50, 20)
$ip = GUICtrlCreateInput("", 70, 100, 150, 20)
$subnet = GUICtrlCreateInput("", 70, 120, 150, 20)
$gateway = GUICtrlCreateInput("", 70, 140, 150, 20)
GUICtrlCreateGroup("DNS Settings", 10, 170, 240, 110)
$autodns = GUICtrlCreateRadio("Obtain DNS Automatically", 20, 190,
150, 20)
$specdns = GUICtrlCreateRadio("Specify DNS", 20, 210, 140, 20)
GUICtrlCreateLabel("DNS 1", 20, 230, 40, 20)
$dns1 = GUICtrlCreateInput("", 70, 230, 150, 20)
GUICtrlCreateLabel("DNS 2", 20, 250, 40, 20)
$dns2 = GUICtrlCreateInput("", 70, 250, 150, 20)
$apply = GUICtrlCreateButton("Apply", 40, 290, 80, 20)
$exit = GUICtrlCreateButton("Exit", 140, 290, 80, 20)
$status = GUICtrlCreateLabel("Ready", 5, 310, 40, 15)
$by = GUICtrlCreateLabel("12/05/2005 - By:Andrew Calcutt", 55, 310,
200, 15)
GUICtrlSetState($by, $GUI_DISABLE)
GUICtrlSetData($status, "Working...")
$line = 4
_RunDOS("netsh inter show interface > " & $tempfile)
While 1
$text = FileReadLine($tempfile, $line)
If @error = -1 Then ExitLoop
If StringTrimRight(StringTrimLeft($text, 30),
StringLen(StringTrimLeft($text, 30)) - 9) = "Dedicated" Then
GUICtrlSetData($connections, StringTrimLeft($text, 47) & "|")
EndIf
$line = $line + 1
WEnd
GUICtrlSetData($status, "Ready")
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $dhcp
_Static("Disable")
Case $msg = $static
_Static("Enable")
Case $msg = $autodns
_DNS("Disable")
Case $msg = $specdns
_DNS("Enable")
Case $msg = $connections
GUICtrlSetData($status, "Working...")
_Static("Clear")
_DNS("Clear")
;Set IP Settings based on current configuration
$line = 2
_RunDOS("netsh inter ip show address > " & $tempfile)
While 1
$text = FileReadLine($tempfile, $line)
If @error = -1 Then ExitLoop
If StringInStr($text, GUICtrlRead($connections)) Then
$line = $line + 1
$text = FileReadLine($tempfile, $line)
If StringInStr($text, "Yes") Then
GUICtrlSetState($dhcp, $GUI_CHECKED)
_Static("Disable")
ExitLoop
Else
GUICtrlSetState($static, $GUI_CHECKED)
_Static("Enable")
While 1
$line = $line + 1
If StringInStr(FileReadLine($tempfile, $line), "IP Address") Then
GUICtrlSetData($ip, StringTrimLeft(FileReadLine($tempfile,
$line), 42))
EndIf
If StringInStr(FileReadLine($tempfile, $line), "SubnetMask") Then
GUICtrlSetData($subnet, StringTrimLeft(FileReadLine($tempfile,
$line), 42))
EndIf
If StringInStr(FileReadLine($tempfile, $line), "Default
Gateway") Then
GUICtrlSetData($gateway,
StringTrimLeft(FileReadLine($tempfile, $line), 42))
EndIf
If StringInStr(FileReadLine($tempfile, $line),
"InterfaceMetric") Then
ExitLoop
EndIf
WEnd
EndIf
EndIf
$line = $line + 1
WEnd
;Set DNS Settings
$line = 2
_RunDOS("netsh inter ip show dns > " & $tempfile)
While 1
$text = FileReadLine($tempfile, $line)
If @error = -1 Then ExitLoop
If StringInStr($text, GUICtrlRead($connections)) Then
$line = $line + 1
$text = FileReadLine($tempfile, $line)
If StringInStr($text, "DHCP") Then
_DNS("Disable")
GUICtrlSetState($autodns, $GUI_CHECKED)
GUICtrlSetData($dns1, StringTrimLeft($text, 42))
$line = $line + 1
$text = FileReadLine($tempfile, $line)
If StringInStr($text, "Register") Then ExitLoop
GUICtrlSetData($dns2, StringTrimLeft($text, 42))
ExitLoop
EndIf
If StringInStr($text, "Statically") Then
_DNS("Enable")
GUICtrlSetState($specdns, $GUI_CHECKED)
GUICtrlSetData($dns1, StringTrimLeft($text, 42))
$line = $line + 1
$text = FileReadLine($tempfile, $line)
If StringInStr($text, "Register") Then ExitLoop
GUICtrlSetData($dns2, StringTrimLeft($text, 42))
ExitLoop
EndIf
Else
$line = $line + 1
EndIf
WEnd
GUICtrlSetData($status, "Ready")
Case $msg = $apply
GUICtrlSetData($status, "Working...")
If GUICtrlRead($dhcp) = 1 Then _RunDOS("netsh inter ip set address
""" & GUICtrlRead($connections) & """ source=dhcp")
If GUICtrlRead($static) = 1 Then
If GUICtrlRead($gateway) = "" Then _RunDOS("netsh inter ip set
address """ & GUICtrlRead($connections) & """ source=static addr=" &
GUICtrlRead($ip) & " mask=" & GUICtrlRead($subnet) & " gateway=none")
If GUICtrlRead($gateway) <> "" Then _RunDOS("netsh inter ip set
address """ & GUICtrlRead($connections) & """ source=static addr=" &
GUICtrlRead($ip) & " mask=" & GUICtrlRead($subnet) & " gateway=" &
GUICtrlRead($gateway) & " 1")
EndIf
If GUICtrlRead($autodns) = 1 Then _RunDOS("netsh inter ip set dns
""" & GUICtrlRead($connections) & """ dhcp")
If GUICtrlRead($specdns) = 1 Then
_RunDOS("netsh inter ip set dns """ & GUICtrlRead($connections) &
""" static " & GUICtrlRead($dns1))
_RunDOS("netsh inter ip add dns """ & GUICtrlRead($connections) &
""" " & GUICtrlRead($dns2) & " index=2")
EndIf
GUICtrlSetData($status, "Ready")
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $exit
ExitLoop
Case Else
;;;
EndSelect
WEnd
FileDelete($tempfile)
Exit
Func _Static($state)
If $state = "Disable" Then
GUICtrlSetState($ip, $GUI_DISABLE)
GUICtrlSetState($subnet, $GUI_DISABLE)
GUICtrlSetState($gateway, $GUI_DISABLE)
EndIf
If $state = "Enable" Then
GUICtrlSetState($ip, $GUI_ENABLE)
GUICtrlSetState($subnet, $GUI_ENABLE)
GUICtrlSetState($gateway, $GUI_ENABLE)
EndIf
If $state = "Clear" Then
GUICtrlSetData($ip, "")
GUICtrlSetData($subnet, "255.255.255.0")
GUICtrlSetData($gateway, "")
EndIf
EndFunc ;==>_Static
Func _DNS($state)
If $state = "Disable" Then
GUICtrlSetState($dns1, $GUI_DISABLE)
GUICtrlSetState($dns2, $GUI_DISABLE)
EndIf
If $state = "Enable" Then
GUICtrlSetState($dns1, $GUI_ENABLE)
GUICtrlSetState($dns2, $GUI_ENABLE)
EndIf
If $state = "Clear" Then
GUICtrlSetData($dns1, "")
GUICtrlSetData($dns2, "")
EndIf
EndFunc ;==>_DNS
Valery
--- In [email protected], "valery_vi" <shehrer1@...> wrote:
>
> Perhaps you need netsh tool:
>
> http://www.windowsnetworking.com/articles_tutorials/Netsh-Part1.html
>
> --- In [email protected], aris_azie <no_reply@> wrote:
> >
> > is there any speed way to change ip, subnet & gateway in winxpsp2
using
> > autoit ver 3.2
> > is there any cmd which i can run and call internet protocol (tcp/ip)
> > properties box instead of right klik my network places - properties -
> > bla bla bla...
> > how about computer management box?
> > i'm not sure maybe can use classname, obj or com but i'm already
tried
> > it all & it's failed...
> >
> > plssssss help me... TQVM.
> >
>