批处理 增加一个变量 5
@colorc@cls@echo[ComputersMAC][Name][ip]>name.xmz@echo44-2A-02-74-AA-1C001001>>name.x...
@color c
@cls
@echo [ComputersMAC] [Name] [ip] >name.xmz
@echo 44-2A-02-74-AA-1C 001 001 >>name.xmz
@echo D6-FF-94-8D-6F-20 002 002 >>name.xmz
@echo 48-FD-98-43-9F-23 003 003 >>name.xmz
@echo 2A-90-0E-29-10-AF 004 004 >>name.xmz
@echo F2-CF-E0-12-0A-6D 005 005 >>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.1.%ip% mask=255.255.255.0 gateway=192.168.1.1 gwmetric=0
del /q *.xmz
del /q *.reg
上面是一个根据MAC修改IP地址和子网掩码的,我想在前面MAC地址@echo 44-2A-02-74-AA-1C 001 001 >>name.xmz再加一个变量,然后后面的source=static addr=192.168.1.%ip%就可以改IP地址的第三位了,即是在前面增加一个变量后面addr=192.168.%x%.%IP%可是不知道在哪增加这个变量可以实现后面的 展开
@cls
@echo [ComputersMAC] [Name] [ip] >name.xmz
@echo 44-2A-02-74-AA-1C 001 001 >>name.xmz
@echo D6-FF-94-8D-6F-20 002 002 >>name.xmz
@echo 48-FD-98-43-9F-23 003 003 >>name.xmz
@echo 2A-90-0E-29-10-AF 004 004 >>name.xmz
@echo F2-CF-E0-12-0A-6D 005 005 >>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.1.%ip% mask=255.255.255.0 gateway=192.168.1.1 gwmetric=0
del /q *.xmz
del /q *.reg
上面是一个根据MAC修改IP地址和子网掩码的,我想在前面MAC地址@echo 44-2A-02-74-AA-1C 001 001 >>name.xmz再加一个变量,然后后面的source=static addr=192.168.1.%ip%就可以改IP地址的第三位了,即是在前面增加一个变量后面addr=192.168.%x%.%IP%可是不知道在哪增加这个变量可以实现后面的 展开
1个回答
展开全部
您试一下吧,大致应该是下面这样。
@color c
@cls
@echo [ComputersMAC] [Name] [x] [ip] >name.xmz
@echo 44-2A-02-74-AA-1C 001 1 001 >>name.xmz
@echo D6-FF-94-8D-6F-20 002 1 002 >>name.xmz
@echo 48-FD-98-43-9F-23 003 1 003 >>name.xmz
@echo 2A-90-0E-29-10-AF 004 1 004 >>name.xmz
@echo F2-CF-E0-12-0A-6D 005 1 005 >>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 x=%%C
for /f "skip=1 tokens=4" %%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.1.%ip% mask=255.255.255.0 gateway=192.168.1.1 gwmetric=0
del /q *.xmz
del /q *.reg
@color c
@cls
@echo [ComputersMAC] [Name] [x] [ip] >name.xmz
@echo 44-2A-02-74-AA-1C 001 1 001 >>name.xmz
@echo D6-FF-94-8D-6F-20 002 1 002 >>name.xmz
@echo 48-FD-98-43-9F-23 003 1 003 >>name.xmz
@echo 2A-90-0E-29-10-AF 004 1 004 >>name.xmz
@echo F2-CF-E0-12-0A-6D 005 1 005 >>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 x=%%C
for /f "skip=1 tokens=4" %%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.1.%ip% mask=255.255.255.0 gateway=192.168.1.1 gwmetric=0
del /q *.xmz
del /q *.reg
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询