批处理实现机房计算机名 ip地址快速配置,win7系统批处理BAT如何批量改ip和机器名?...

@color c

@cls

@echo    [ComputersMAC]        [Name]  [ip]     >name.xmz

@echo  74-27-EA-34-02-CBA01111>>name.xmz

@echo  74-27-EA-16-50-18A02112>>name.xmz

@cls

ipconfig /all >ipconfig.xmz

find "Physical Address" ipconfig.xmz >mac.xmz

for /f "skip=1 tokens=12" %%C in (mac.xmz) do set mac=%%C

find "%mac%" name.xmz >key.xmz

for /f "skip=1 tokens=2" %%C in (key.xmz) do set name=%%C

for /f "skip=1 tokens=3" %%C in (key.xmz) do set ip=%%C

@echo %name%

@echo %ip%

@echo Windows Registry Editor Version 5.00 >Cname.reg

@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName] >>Cname.reg

@echo "ComputerName"="%name%" >>Cname.reg

@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] >>Cname.reg

@echo "NV Hostname"="%name%" >>Cname.reg

@echo "Hostname"="%name%" >>Cname.reg

@echo Windows Registry Editor Version 5.00 >insn.reg

@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] >>insn.reg

@echo "VirtualNetworkNumber"=dword:00000%name% >>insn.reg

@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NwlnkIpx\Parameters] >>insn.reg

@echo "VirtualNetworkNumber"=dword:00000%name% >>insn.reg

regedit /s Cname.reg

regedit /s insn.reg

netsh interface ip set address name="本地连接" source=static addr=192.168.7.%ip% mask=255.255.255.0 gateway=192.168.7.1 gwmetric=0

netsh interface ip set dns name="本地连接" source=static addr=202.99.192.68

netsh interface ip add dns name="本地连接" addr=202.99.192.66 index=2

del /q *.xmz

del /q *.reg

shutdown -r -t 5

del %0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值