windows 无盘机,更新主机名.

本文介绍了一种通过VBS脚本自动更新无盘机主机名的方法。该脚本会在开机时从指定URL获取新的主机名,并使用Windows注册表API进行主机名设置,确保每台无盘机都有唯一的主机名。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

同用一个镜像的无盘机,开机后更新主机名.

 

写个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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值