以前写的,调用devcon,参考一下#include <ACN_NET.au3>
#include<process.au3>
Break(0)
TrayTip(" 初始化信息 ", "重启网卡中请稍等…", 120, 1)
Dim $i
While $i < 6
$m = _RunDOS('' netsh interface ip set address name = "本地连接" '' & $i & '' source = dhcp'')
$n = _RunDOS('' netsh interface ip set dns "本地连接" '' & $i & '' source = dhcp'')
$i += 1
WEnd
RunWait("devcon restart =net pci\*", "", @SW_HIDE)
Sleep(3000)
TrayTip(" 正在获取DHCP信息 ", " 完成进度的30%…请稍候", 120, 1)
$info = _NetworkAdapterInfo()
$T1 = $info[1][4];IP地址
$T2 = $info[1][7];子网掩码
$T3 = $info[1][2];默认网关
$T4 = $info[1][5];主DNS
$T5 = $info[1][6];次DNS
$T6 = $info[1][1];网卡名称
$T7 = $info[1][3];主机名称
$T8 = $info[1][8];MAC地址
$T9 = $info[1][9];连接名称
MsgBox(1, "", "网卡名称:" & $T6 & @CRLF & "连接名称:" & $T9 & @CRLF & "主机名称:" & $T7 & @CRLF & "IP地址:" & $T1 & @CRLF & "子网掩码:" & $T2 & @CRLF & "默认网关:" & $T3 & @CRLF & "主DNS:" & $T4 & @CRLF & "次DNS:" & $T5 & @CRLF & "MAC地址:" & $T8, 3)
Sleep(1000)
TrayTip(" 正在设置固定IP ", "完成进度的60%…请稍候", 120, 1)
_WMI_SetNetworkAdapterInfo(@ComputerName, $T1, $T2, $T3, $T4, $T5, 0)
Sleep(3000)
Dim $Tip = @IPAddress1
Dim $Nip = StringSplit($Tip, ".")
TrayTip(" 正在设置机器名", " 完成进度的90%…请稍候", 120, 1)
Dim $NewName = "LPXX_" & Int(StringFormat("%03d\n", $Nip[4]))
Sleep(1000)
$_Return = DllCall("Kernel32.dll", "int", "SetComputerNameEx", "int", 5, "str", $NewName)
If $_Return[0] <> 0 Then MsgBox(0, "", "新的主机器名是:" & $NewName & @LF & "建议重启电脑生效!", 2)
TrayTip("结束", "完成进度的100%,所有信息设置完毕", 0)
Exit
|