找回密码
 加入
搜索
查看: 994|回复: 1

根据mac地址同步机器名的错误问题!

[复制链接]
发表于 2009-3-21 16:05:26 | 显示全部楼层 |阅读模式
$sky=mac()

Func mac()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output=""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled != 0", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
   For $objItem In $colItems
      $Output1 = $Output & "" & $objItem.MACAddress & @CRLF
   Next
Return $Output1
Else
Endif
EndFunc

$Hostname = StringReplace($sky,":","")

RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName","REG_SZ",$Hostname)
RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Hostname)
RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters","Hostname","REG_SZ",$Hostname)


改过机器名后,在计算机管理里本地用户和组提示语法错误,在修改计算机名字里似乎有空字符,请哪位高手指正一下!谢谢!

[ 本帖最后由 电脑考拉 于 2009-3-22 21:12 编辑 ]
 楼主| 发表于 2009-3-22 21:11:57 | 显示全部楼层

我的错

多了一个 @CRLF
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 10:47 , Processed in 0.071402 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表