你好:

     感谢你访问我的 Blog ,本博客只提供博主的技术经验分享,你可以在此做简单的留言和评论,我会抽空回复你;若是要深入交流探讨,请联系QQ:47853253或者加QQ群:12012081


 

IP设置程序1.0【Au3】脚本

 #Region ;**** 参数创建于 ACNWrapper_GUI ****

#AutoIt3Wrapper_icon=..\..\..\tools\高清ICO\themes.ico
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#cs ____________________________________
Au3 版本: 汉化版本 1.76
脚本作者: 思想在祼奔
网站支持: http://wdqq.f3322.net/
Email:    47853253@qq.com
QQ/TM:    47853253
脚本编号: ip设置程序
#ce ____________________________________
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <IPAddressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GuiIPAddress.au3>
#include <GuiEdit.au3>
#include <ComboConstants.au3>
Opt("TrayMenuMode", 3) ; 默认菜单项目 (脚本暂停中/退出)(Script Paused/Exit) 将不会显示,并且所选项目不能被选中(checkbox不会打勾) . 请参考TrayMenuMode选项1和2(3=1+2).
Local $aboutitem    = TrayCreateItem("关于")
TrayCreateItem("")
Local $exititem = TrayCreateItem("退出")
TraySetState()
Global const $formname = "内部专用IP设置程序"
Global $formp = GUICreate($formname,337,307,-1,-1)
;break(0)
HotKeySet("!x", "terminate");定义退出热键,退出为:alt+x !:代表alt,+:shift,^:代表ctrl.退出函数为:Terminate,在后边。
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("【彝岭科技】专用IP设置程序——by:47853253", 619, 443, 650, 320)
$Label1 = GUICtrlCreateLabel("            哥修的不是电脑,是寂寞。", 0, 0, 619, 40)
GUICtrlSetFont(-1, 24, 800, 2, "微软雅黑")
GUICtrlSetBkColor(-1, 0x3399FF)
$Label2 = GUICtrlCreateLabel("                           彝岭电脑科技", 0, 424, 619, 20)
GUICtrlSetFont(-1, 14, 50, 0, "黑体")
GUICtrlSetBkColor(-1, 0x800080)
$Label3 = GUICtrlCreateLabel("内部专用IP设置程序", 220, 64, 194, 23)
GUICtrlSetFont(-1, 14, 800, 0, "黑体")
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 56, 136, 130, 21)
_GUICtrlIpAddress_Set($IPAddress1, "192.168.1.123")
$IPAddress2 = _GUICtrlIpAddress_Create($Form1, 56, 176, 130, 21)
_GUICtrlIpAddress_Set($IPAddress2, "255.255.255.0")
$IPAddress3 = _GUICtrlIpAddress_Create($Form1, 272, 136, 130, 21)
_GUICtrlIpAddress_Set($IPAddress3, "192.168.100.123")
$IPAddress4 = _GUICtrlIpAddress_Create($Form1, 272, 176, 130, 21)
_GUICtrlIpAddress_Set($IPAddress4, "255.255.255.0")
$IPAddress5 = _GUICtrlIpAddress_Create($Form1, 56, 216, 130, 21)
_GUICtrlIpAddress_Set($IPAddress5, "192.168.1.254")
$IPAddress6 = _GUICtrlIpAddress_Create($Form1, 56, 256, 130, 21)
_GUICtrlIpAddress_Set($IPAddress6, "222.172.200.68")
$IPAddress7 = _GUICtrlIpAddress_Create($Form1, 272, 216, 130, 21)
_GUICtrlIpAddress_Set($IPAddress7, "192.168.100.1")
$IPAddress8 = _GUICtrlIpAddress_Create($Form1, 272, 256, 130, 21)
_GUICtrlIpAddress_Set($IPAddress8, "222.172.200.68")
$IPAddress9 = _GUICtrlIpAddress_Create($Form1, 56, 296, 130, 21)
_GUICtrlIpAddress_Set($IPAddress9, "61.166.150.123")
$IPAddress10 = _GUICtrlIpAddress_Create($Form1, 272, 296, 130, 21)
_GUICtrlIpAddress_Set($IPAddress10, "61.166.150.123")
$IPAddress11 = _GUICtrlIpAddress_Create($Form1, 480, 136, 130, 21)
_GUICtrlIpAddress_Set($IPAddress11, "192.168.0.123")
$IPAddress12 = _GUICtrlIpAddress_Create($Form1, 480, 176, 130, 21)
_GUICtrlIpAddress_Set($IPAddress12, "255.255.255.0")
$IPAddress13 = _GUICtrlIpAddress_Create($Form1, 480, 216, 130, 21)
_GUICtrlIpAddress_Set($IPAddress13, "192.168.0.1")
$IPAddress14 = _GUICtrlIpAddress_Create($Form1, 480, 256, 130, 21)
_GUICtrlIpAddress_Set($IPAddress14, "222.172.200.68")
$IPAddress15 = _GUICtrlIpAddress_Create($Form1, 480, 296, 130, 21)
_GUICtrlIpAddress_Set($IPAddress15, "61.166.150.123")
$Label4 = GUICtrlCreateLabel("IP:", 0, 136, 51, 18)
GUICtrlSetFont(-1, 11, 800, 0, "宋体")
$Label5 = GUICtrlCreateLabel("掩码:", 0, 176, 47, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label6 = GUICtrlCreateLabel("网关:", 0, 216, 47, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label7 = GUICtrlCreateLabel("DNS1:", 0, 256, 57, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label8 = GUICtrlCreateLabel("DNS2:", 0, 296, 49, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label9 = GUICtrlCreateLabel("IP:", 208, 144, 39, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label10 = GUICtrlCreateLabel("掩码:", 208, 184, 56, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label11 = GUICtrlCreateLabel("网关:", 208, 216, 55, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label12 = GUICtrlCreateLabel("DNS1:", 208, 256, 57, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label13 = GUICtrlCreateLabel("DNS2:", 208, 296, 57, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label14 = GUICtrlCreateLabel("IP:", 432, 136, 39, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label15 = GUICtrlCreateLabel("掩码:", 432, 176, 48, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label16 = GUICtrlCreateLabel("网关:", 432, 216, 48, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label17 = GUICtrlCreateLabel("DNS1:", 432, 256, 41, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label18 = GUICtrlCreateLabel("DNS2:", 432, 296, 41, 20)
GUICtrlSetFont(-1, 12, 800, 0, "宋体")
$Label19 = GUICtrlCreateLabel("【方案一】办公室", 48, 104, 140, 20)
GUICtrlSetFont(-1, 12, 800, 0, "楷体")
GUICtrlSetBkColor(-1, 0xFF00FF)
$Label20 = GUICtrlCreateLabel("", 320, 112, 4, 4)
$Label21 = GUICtrlCreateLabel("【方案三】自定义", 472, 104, 140, 20)
GUICtrlSetFont(-1, 12, 800, 0, "楷体")
GUICtrlSetBkColor(-1, 0xFFFF00)
$Button1 = GUICtrlCreateButton("设 定", 56, 352, 131, 25, 0)
GUICtrlSetFont(-1, 14, 800, 0, "仿宋")
GUICtrlSetBkColor(-1, 0x008080)
GUICtrlSetCursor (-1, 0)
GUICtrlSetColor(-1, 0xFF0000)
$Button2 = GUICtrlCreateButton("设 定", 272, 352, 131, 25, 0)
GUICtrlSetFont(-1, 14, 800, 0, "仿宋")
GUICtrlSetBkColor(-1, 0x008080)
GUICtrlSetCursor (-1, 0)
GUICtrlSetColor(-1, 0xFF0000)
$Button3 = GUICtrlCreateButton("设 定", 480, 352, 131, 25, 0)
GUICtrlSetFont(-1, 14, 800, 0, "仿宋")
GUICtrlSetBkColor(-1, 0x008080)
GUICtrlSetCursor (-1, 0)
GUICtrlSetColor(-1, 0xFF0000)
$Label22 = GUICtrlCreateLabel("【方案二】家庭", 280, 104, 123, 20)
GUICtrlSetFont(-1, 12, 800, 0, "楷体")
GUICtrlSetBkColor(-1, 0x008000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
 
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $Button1
_setip1 ()
msgbox(0,"状态","【方案一】办公室 方案 设置完成")
case $Button2
_setip2 ()
msgbox(0,"状态","【方案二】家庭 方案 设置完成")
case $Button3
_setip3 ()
msgbox(0,"状态","【方案三】自定义 方案 设置完成")
EndSwitch
    Local $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $aboutitem
            MsgBox(64, "关于", "【彝岭科技】专用IP设置程序——by:47853253")
        Case $msg = $exititem
            ExitLoop
    EndSelect
WEnd
 
 
;定义退出函数
Func Terminate()
    Exit 0
EndFunc
 
Func _setip1 ()
local $Name = "本地连接"
local $IP = _GUICtrlIpAddress_Get($IPAddress1)
local $Mask = _GUICtrlIpAddress_Get($IPAddress2)
local $GateWay = _GUICtrlIpAddress_Get($IPAddress5)
local $pDNS = _GUICtrlIpAddress_Get($IPAddress6)
local $sDNS = _GUICtrlIpAddress_Get($IPAddress9)
;msgbox(0,"",$Mask)
;exit
progressOn("【方案一】办公室","正在设置网络,请稍候。。。。。","",-1,-1,$formp);设置IP, 有进度条
Switch @OSVersion
Case "WIN_2000", "WIN_XP", "WIN_2003"
ProgressSet(20, "设置IP地址和子网掩码……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set address name="' & _
$Name & '" source=static addr=' & $IP & _
' mask=' & $Mask, "", @SW_HIDE)
ProgressSet(40, "设置默认网关……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set address name="' & _
$Name & '" gateway=' & $GateWay & _
' gwmetric=0', "", @SW_HIDE)
ProgressSet(60, "设置首选DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set dns name="' & _
$Name & '" source=static addr=' & $pDNS & _
' register=PRIMARY', "", @SW_HIDE)
ProgressSet(80, "设置备用DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip add dns name="' & _
$Name & '" addr=' & $sDNS, "", @SW_HIDE)
ProgressSet(100, "完成设置……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set wins name="' & _
$Name & '" source=static addr=none', _ 
"", @SW_HIDE)
Case "WIN_VISTA", "WIN_2008", "WIN_7", "WIN_2008R2"
ProgressSet(40, "设置IP地址、子网掩码、默认网关……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 set address name="' & _
$Name & '" source=static addr=' & $IP & _
' mask=' & $Mask & ' gateway=' & $GateWay, _
"", @SW_HIDE)
ProgressSet(60, "设置首选DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 set dns name="' & _
$Name & '" source=static addr=' & $pDNS & _
' register=PRIMARY', "", @SW_HIDE)
ProgressSet(80, "设置备用DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 add dns name="' & _
$Name & '" addr=' & $sDNS, "", @SW_HIDE)
ProgressSet(100, "完成设置……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 set wins name="' & _
$Name & '" source=static addr=none', _ 
"", @SW_HIDE)
EndSwitch
progressOff()  ;关闭进度条
EndFunc  ;结束函数
Func _setip2 ()
local $Name = "本地连接"
local $IP = _GUICtrlIpAddress_Get($IPAddress3)
local $Mask = _GUICtrlIpAddress_Get($IPAddress4)
local $GateWay = _GUICtrlIpAddress_Get($IPAddress7)
local $pDNS = _GUICtrlIpAddress_Get($IPAddress8)
local $sDNS = _GUICtrlIpAddress_Get($IPAddress10)
progressOn("【方案一】办公室","正在设置网络,请稍候。。。。。","",-1,-1,$formp);设置IP, 有进度条
Switch @OSVersion
Case "WIN_2000", "WIN_XP", "WIN_2003"
ProgressSet(20, "设置IP地址和子网掩码……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set address name="' & _
$Name & '" source=static addr=' & $IP & _
' mask=' & $Mask, "", @SW_HIDE)
ProgressSet(40, "设置默认网关……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set address name="' & _
$Name & '" gateway=' & $GateWay & _
' gwmetric=0', "", @SW_HIDE)
ProgressSet(60, "设置首选DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set dns name="' & _
$Name & '" source=static addr=' & $pDNS & _
' register=PRIMARY', "", @SW_HIDE)
ProgressSet(80, "设置备用DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip add dns name="' & _
$Name & '" addr=' & $sDNS, "", @SW_HIDE)
ProgressSet(100, "完成设置……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set wins name="' & _
$Name & '" source=static addr=none', _ 
"", @SW_HIDE)
Case "WIN_VISTA", "WIN_2008", "WIN_7", "WIN_2008R2"
ProgressSet(40, "设置IP地址、子网掩码、默认网关……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 set address name="' & _
$Name & '" source=static addr=' & $IP & _
' mask=' & $Mask & ' gateway=' & $GateWay, _
"", @SW_HIDE)
ProgressSet(60, "设置首选DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 set dns name="' & _
$Name & '" source=static addr=' & $pDNS & _
' register=PRIMARY', "", @SW_HIDE)
ProgressSet(80, "设置备用DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 add dns name="' & _
$Name & '" addr=' & $sDNS, "", @SW_HIDE)
ProgressSet(100, "完成设置……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 set wins name="' & _
$Name & '" source=static addr=none', _ 
"", @SW_HIDE)
EndSwitch
progressOff()  ;关闭进度条
EndFunc  ;结束函数
Func _setip3 ()
local $name = "本地连接"
local $ip = _GUICtrlIpAddress_Get($IPAddress11)
local $mask = _GUICtrlIpAddress_Get($IPAddress12)
local $gateway = _GUICtrlIpAddress_Get($IPAddress13)
local $pdns = _GUICtrlIpAddress_Get($IPAddress14)
local $sdns = _GUICtrlIpAddress_Get($IPAddress15)
progressOn("【方案一】办公室","正在设置网络,请稍候。。。。。","",-1,-1,$formp);设置IP, 有进度条
Switch @OSVersion
Case "WIN_2000", "WIN_XP", "WIN_2003"
ProgressSet(20, "设置IP地址和子网掩码……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set address name="' & _
$Name & '" source=static addr=' & $IP & _
' mask=' & $Mask, "", @SW_HIDE)
ProgressSet(40, "设置默认网关……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set address name="' & _
$Name & '" gateway=' & $GateWay & _
' gwmetric=0', "", @SW_HIDE)
ProgressSet(60, "设置首选DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set dns name="' & _
$Name & '" source=static addr=' & $pDNS & _
' register=PRIMARY', "", @SW_HIDE)
ProgressSet(80, "设置备用DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip add dns name="' & _
$Name & '" addr=' & $sDNS, "", @SW_HIDE)
ProgressSet(100, "完成设置……")
RunWait(@ComSpec & " /c " & _
'netsh interface ip set wins name="' & _
$Name & '" source=static addr=none', _ 
"", @SW_HIDE)
Case "WIN_VISTA", "WIN_2008", "WIN_7", "WIN_2008R2"
ProgressSet(40, "设置IP地址、子网掩码、默认网关……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 set address name="' & _
$Name & '" source=static addr=' & $IP & _
' mask=' & $Mask & ' gateway=' & $GateWay, _
"", @SW_HIDE)
ProgressSet(60, "设置首选DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 set dns name="' & _
$Name & '" source=static addr=' & $pDNS & _
' register=PRIMARY', "", @SW_HIDE)
ProgressSet(80, "设置备用DNS服务器……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 add dns name="' & _
$Name & '" addr=' & $sDNS, "", @SW_HIDE)
ProgressSet(100, "完成设置……")
RunWait(@ComSpec & " /c " & _
'netsh interface ipv4 set wins name="' & _
$Name & '" source=static addr=none', _ 
"", @SW_HIDE)
EndSwitch
progressOff()  ;关闭进度条
EndFunc  ;结束函数
 


文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
评论: 0 | 引用: 0 | 查看次数: 134
发表评论
你没有权限发表留言!