电脑考拉 发表于 2009-3-21 16:05:26

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

$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
页: [1]
查看完整版本: 根据mac地址同步机器名的错误问题!