同用一个镜像的无盘机,开机后更新主机名.
写个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