论坛中的“批处理如何根据机器名和IP修改IPX”一文中的批处理命令
@echo off
for /f "tokens=16 delims=." %%a in ('ipconfig ^| findstr "IP Address"') do set netkey=%%a
REG add "HKLM\SYSTEM\CurrentControlSet\Services\NwlnkIpx\Parameters" /v VirtualNetworkNumber /t REG_DWORD /d %netkey% /f
发现写入注册表的VirtualNetworkNumber 时是用十进制方式写入的,也就是说如果IP是201.则内部网络号会变成C9,请问能用16进制的方式来写入吗?
从版主说的链接中找到了十六进制转换为十进制的BATCH,结合到上面说的批处理中,结果失败。请教下问题出在哪啊。。。
命令如下:
@echo off
set /p name=输入计算机名:PC
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d PC%name% /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d PC%name% /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d PC%name% /f
@echo off
set /p slection1=请输入IP地址: 192.168.1.
netsh interface ip set address name="本地连接" source=static addr="192.168.1.%slection1%" mask=255.255.255.0
@echo off
(set /a str=9,n=1,num=0)
for /f "tokens=16 delims=." %%a in ('ipconfig ^| findstr "IP Address"') do set var=%%a
for %%a in (0 1 2 3 4 5 6 7 8 9 A B C D E F) DO (
call set var=%%var:%%a=%%a %%
)
for %%a in (%var%) do call set max=%%a %%max%%
for %%a in (A B C D E F) do (
set /a str+=1
call set %%a=%%str%%
)
for %%a in (%max%) do (
set /a num=%%a*n+num
set /a n*=16
)
REG add "HKLM\SYSTEM\CurrentControlSet\Services\NwlnkIpx\Parameters" /v VirtualNetworkNumber /t REG_DWORD /d %num% /f
pause