同用一个镜像的无盘机,开机后更新主机名.
写个run.vbs脚机,在本地策略中开机后运行.
On Error Resume Next
urp="http://192.168.0.110/pxe/"
URL=urp & "hostname.php"
Set Http = CreateObject("Microsoft.XMLHTTP")
Http.Open "GET",URL,FALSE
Http.Send
pagestatus = Http.status
if NOT pagestatus="200" then
URLGet="Error:" & pagestatus
return
Else
'URLGet = Http.ResponseBody
URLGet = Http.responseText
end If
URL=urp & "aoedisk.php?" & now
Set Http = CreateObject("Microsoft.XMLHTTP")
Http.Open "GET",URL,FALSE
Http.Send
pagestatus = Http.status
if NOT pagestatus="200" then
URLGet="Error:" & pagestatus
Else
'URLGet = Http.ResponseBody
aoedisk = Http.responseText
end If
Set WSHShell = CreateObject("WScript.Shell")
RegKeyCompName = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\"
RegKeyTCPIP = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\"
NewName = URLGet
NewNameU = UCase(NewName)
NewNameL = LCase(NewName)
With WSHShell
.RegDelete RegKeyTCPIP & "Hostname"
.RegDelete RegKeyTCPIP & "NV Hostname"
.RegWrite RegKeyCompName & "ComputerName\ComputerName", NewNameU
.RegWrite RegKeyCompName & "ActiveComputerName\ComputerName", NewNameU
.RegWrite RegKeyTCPIP & "Hostname", NewNameL
.RegWrite RegKeyTCPIP & "NV Hostname", NewNameL
End With
if not aoedisk="none" then
WSHShell.run aoedisk
end if
无盘机主机名更新
本文介绍了一种通过VBS脚本自动更新无盘机主机名的方法。该脚本会在开机时从指定URL获取新的主机名,并使用Windows注册表API进行主机名设置,确保每台无盘机都有唯一的主机名。
300

被折叠的 条评论
为什么被折叠?



