打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
AU3-根据MAC地址对应表修改计算机名、IP、CS-CDKEY
  • #NoTrayIcon
  • $g_szVersion = "MacToIp 2.3"
  • If WinExists($g_szVersion) Then Exit
  • AutoItWinSetTitle($g_szVersion)
  • HotKeySet("{ESC}", "_Terminate")
  • Dim $Msg = '计算机修改信息。' & @CRLF & @CRLF
  • If Not @OSType = "WIN32_NT" OR Not @OSLang = "0804" then;判断是否支持此系统
  • MsgBox(16, "错误……Make By Amu", "本工具不支持此系统", 10)
  • Exit
  • EndIf
  • ;设置配置文件路径
  • $Mac2Ip = "Mac2Ip.ini"
  • If Not FileExists($Mac2Ip) Then
  • $Mac2Ip = @ScriptDir & "\Mac2Ip.ini"
  • If Not FileExists($Mac2Ip) Then
  • $Mac2Ip = @WorkingDir & "\Mac2Ip.ini"
  • EndIf
  • EndIf
  • If Not FileExists($Mac2Ip) Then
  • MsgBox(64, "错误……Make By Amu", '没有找到配置文件"' & $Mac2Ip & '"' & @CRLF & '或"' & $Mac2Ip & '"不在同一目录下', 15)
  • Exit
  • EndIf
  • $LocMAC = _GetLocalMAC()
  • If $LocMAC[0] = 0 Then
  • MsgBox(64, "错误……Make By Amu", '找不到本机MAC地址,' & @CRLF & '请检查本机配置!', 15)
  • Exit
  • Else
  • For $m = 1 to $LocMAC[0]
  • $info = IniRead($Mac2Ip, "Mac2Ip", $LocMAC[$m], "")
  • If $info <> "" Then ExitLoop
  • Next
  • EndIf
  • $info = StringSplit($info, "|")
  • If $info[0] < 2 Then Dim $info[3]
  • $PcName = _StringIsComputerName($info[1])
  • While @error
  • $info[1] = InputBox("输入的新计算机名格式不对。", '请重新设置计算机名!' & @CRLF & @CRLF & '标准名称可以含有字母(a-z, A-Z)、数字(0-9)和连字符(-),但不能含有空格或句号(.)。名称可能不完全是数字。', "", " M63")
  • If @error Then _Terminate()
  • $PcName = _StringIsComputerName($info[1])
  • If Not @error Then ExitLoop
  • WEnd
  • $PcName = $info[1]
  • $Msg = $Msg & "计算机名 ....: " & $PcName & @CRLF
  • $ipAdd = _StringIsIP($info[2])
  • While @error
  • $info[2] = InputBox("IP地址格式错误", "请重新输入IP地址!", "", " M15", 1, 1, @DesktopWidth/2-95, @DesktopHeight/2-72)
  • If @error Then _Terminate()
  • $ipAdd = _StringIsIP($info[2])
  • If Not @error Then ExitLoop
  • WEnd
  • $Msg = $Msg & "IP地址 ....: " & $ipAdd & @CRLF
  • $Mask = _StringIsIP(IniRead($Mac2Ip, "Setting", "Mask", "255.255.255.0"))
  • While @error
  • $Mask = InputBox("子网掩码格式错误", "请重新输入子网掩码!", "", " M15", 1, 1, @DesktopWidth/2-95, @DesktopHeight/2-72)
  • If @error Then _Terminate()
  • $Mask = _StringIsIP($Mask)
  • If Not @error Then ExitLoop
  • WEnd
  • $Msg = $Msg & "子网掩码 ....: " & $Mask & @CRLF
  • $Gateway = _StringIsIP(IniRead($Mac2Ip, "Setting", "GateWay", "192.168.0.1"))
  • While @error
  • $Gateway = InputBox("默认网关格式错误", "请重新输入网关!", "", " M15", 1, 1, @DesktopWidth/2-95, @DesktopHeight/2-72)
  • If @error Then _Terminate()
  • $Gateway = _StringIsIP($Gateway)
  • If Not @error Then ExitLoop
  • WEnd
  • $Msg = $Msg & "默认网关 ....: " & $Gateway & @CRLF
  • $CsKey = IniReadSection($Mac2Ip, "Cs15Key")
  • If @error Then
  • $CsKey = 0
  • Else
  • $n = Random(1, $CsKey[0][0], 1)
  • $CsKey = IniRead($Mac2Ip, "Cs15Key", $n, "1234567890123")
  • EndIf
  • If $CsKey <> 0 Then $Msg = $Msg & "CS-CDKEY ....: " & $CsKey & @CRLF
  • $OK = MsgBox(33,"请确认......Make By Amu", $Msg, 5)
  • If $OK = 2 Then _Terminate()
  • $SetName = _SetComputerName($PcName)
  • $SetIpAdd = _SetIPAddress($ipAdd, $Mask, $Gateway)
  • If $CsKey <> 0 Then RegWrite("HKCU\Software\Valve\CounterStrike\Settings", "key", "REG_SZ", $CsKey)
  • Func _SetIPAddress($ipAdd, $Mask = "255.255.255.0", $Gateway = "")
  • $Return = 0
  • $ipAdd = _StringIsIP($ipAdd)
  • If $ipAdd = "" Then $Return = $Return + 1
  • $Mask = _StringIsIP($Mask)
  • If $Mask = "" Then $Return = $Return + 2
  • $Gateway = _StringIsIP($Gateway)
  • If $Gateway = "" Then $Return = $Return + 4
  • Dim $LocalIPAddress[1] = [$ipAdd]
  • Dim $strSubnetMask[1] = [$Mask]
  • Dim $strGateway[1] = [$Gateway]
  • Dim $strGatewayMetric[1] = [1]
  • $strComputer = "localhost"
  • $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "oot\cimv2")
  • $colNetAdapters = $objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
  • If IsObj($colNetAdapters) Then
  • For $objNetAdapter in $colNetAdapters
  • If BitAND($Return, 1) = 0 AND BitAND($Return, 2) = 0 Then $objNetAdapter.EnableStatic($LocalIPAddress, $strSubnetMask)
  • If BitAND($Return, 4) = 0 Then $objNetAdapter.SetGateways($strGateway, $strGatewayMetric)
  • Next
  • EndIf
  • Return $Return
  • EndFunc ;_SetIPAddress修改IP地址
  • Func _SetComputerName($strComputerName)
  • $SetKey1 = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\"
  • $CtrlKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\"
  • $Return = RegWrite ($SetKey1 & "Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $strComputerName)
  • RegWrite ($SetKey1 & "Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $strComputerName)
  • RegWrite ($SetKey1 & "Services\Tcpip\Parameters", "Hostname", "REG_SZ", $strComputerName)
  • RegWrite ($CtrlKey & "Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $strComputerName)
  • RegWrite ($CtrlKey & "Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $strComputerName)
  • RegWrite ($CtrlKey & "Services\Tcpip\Parameters", "Hostname", "REG_SZ", $strComputerName)
  • Return $Return
  • EndFunc ;_SetComputerName修改计算机名
  • Func _GetLocalMAC()
  • Dim $aNULL[1] = [0]
  • $MAC = Chr(13)
  • $strComputer = "localhost"
  • $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "oot\cimv2")
  • $colNicConfigs = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
  • If IsObj($colNicConfigs) Then
  • For $objItem In $colNicConfigs
  • $objNic = $objWMIService.Get ("Win32_NetworkAdapter.DeviceID=" & $objItem.Index)
  • $MAC = $MAC & Chr(10) & $objNic.MACAddress
  • Next
  • $MAC = StringReplace($MAC, Chr(13) & Chr(10), "")
  • If StringInStr($MAC, ":") = 0 Then
  • SetError(2)
  • Return $aNULL
  • Else
  • $MAC = StringReplace($MAC, ":", "-")
  • Return StringSplit($MAC, Chr(10))
  • EndIf
  • Else
  • SetError(1)
  • Return $aNULL
  • EndIf
  • EndFunc ;_GetLocalMAC获取本地MAC地址
  • Func _StringIsComputerName($strComputerName, $ShowMsgBox=1)
  • If $strComputerName = "" OR StringLen($strComputerName) > 63 Then
  • $err = '输入的新计算机名格式不对。标准名称可以含有字母(a-z, A-Z)、数字(0-9)和连字符(-),但不能含有空格或句号(.)。名称可能不完全是数字。'
  • SetError(1)
  • Return 0
  • ElseIf StringIsDigit($strComputerName) = 1 Then
  • If @OSVersion = "WIN_2000" Then
  • $Title = "网络标识"
  • Else
  • $Title = "计算机名更改"
  • EndIf
  • If $ShowMsgBox=1 Then MsgBox(48, $Title, '新计算机名 "' & $strComputerName & '" 是一个数字。名称不应是数字。')
  • SetError(2)
  • Return 0
  • EndIf
  • $NoText = [email=]'`~!@#$[/email]. ^&*()=+[]{}\|;:' & Chr(39) & '",<>/?'
  • For $i = 1 To StringLen($strComputerName)
  • If StringInStr($NoText, StringMid($strComputerName, $i, 1)) <> 0 Then
  • If @OSVersion = "WIN_2000" Then
  • $Title = "网络标识"
  • $Text = '新计算机名 "' & $strComputerName & '" 包括非法的字符。'
  • Else
  • $Title = "计算机名更改"
  • $Text = '新计算机名 "' & $strComputerName & '" 包括不允许的字符。不允许的字符包括 ` ~ ! @ # $ ^ & * ( ) = + [ ] { } \ | ; : ' & Chr(39) & ' " , < > / 和 ?'
  • EndIf
  • If $ShowMsgBox = 1 Then MsgBox(48, $Title, $Text)
  • SetError(3)
  • Return 0
  • EndIf
  • Next
  • If $ShowMsgBox <> 1 Then Return 1
  • $Text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
  • For $i = 1 To StringLen($strComputerName)
  • If StringInStr($Text, StringMid($strComputerName, $i, 1)) = 0 Then
  • If @OSVersion = "WIN_2000" Then
  • $Title = "网络标识"
  • Else
  • $Title = "计算机名更改"
  • EndIf
  • $iMsgBoxAnswer = MsgBox(48+4, $Title, '计算机名 "' & $strComputerName & '" 含有一个或一个以上非标准字符。标准字符包括字母(A-Z,a-z)、数字(0-9)和连字符(-)。如使用非标准字符名称,除非您所属网络使用 Microsoft DNS 服务器,否则其他用户就会在网络上找不到您的计算机。要使用这个非标准名称吗?')
  • If $iMsgBoxAnswer = 6 Then
  • Return 1
  • Else
  • SetError(4)
  • Return 0
  • EndIf
  • EndIf
  • Next
  • EndFunc ; _StringIsComputerName判断计算机名是否正确
  • Func _StringIsIP($strIP)
  • $str = StringSplit($strIP, ".")
  • If $str[0] <> 4 Then
  • SetError(1)
  • return ('')
  • ElseIf StringIsDigit($str[1]) <> 1 OR StringIsDigit($str[2]) <> 1 OR StringIsDigit($str[3]) <> 1 OR StringIsDigit($str[4]) <> 1 Then
  • SetError(2)
  • return ('')
  • ElseIf $str[1] > 255 OR $str[2] > 255 OR $str[3] > 255 OR $str[4] > 255 Then
  • SetError(3)
  • return ('')
  • Else
  • return (Int($str[1]) & "." & Int($str[2]) & "." & Int($str[3]) & "." & Int($str[4]))
  • EndIf
  • EndFunc ;_StringIsIP判断IP格式是否正确
  • Func _Terminate()
  • ToolTip("正在退出……" & @CR & "谢谢使用" & @CR & @YEAR & "年" & @MON & "月" & @MDAY & "日", @DesktopWidth-90, @DesktopHeight-71)
  • Sleep(3000)
  • Exit 0
  • EndFunc
  • 本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
    打开APP,阅读全文并永久保存 查看更多类似文章
    猜你喜欢
    类似文章
    【热】打开小程序,算一算2024你的财运
    如何实现数据从 txt/word 自动导入到excel中
    宽带路由器常见故障巧排除
    The following files from Microsoft's WAIK
    查看计算机的IP地址和MAC地址
    通过js获取计算机内网ip,计算机名,mac地址
    路由器tp-link设置图解_风中的小草
    更多类似文章 >>
    生活服务
    热点新闻
    分享 收藏 导长图 关注 下载文章
    绑定账号成功
    后续可登录账号畅享VIP特权!
    如果VIP功能使用有故障,
    可点击这里联系客服!

    联系客服