联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
setlocal EnableDelayedExpansion :_interface for /f "tokens=1* delims=:" %%i in ('ipconfig /all^|find /i "Physical Address"') do set mac=%%j for /f "tokens=1" %%i in ('type mac.txt^|find /i "%mac:~-18%"') do set ip=%%i for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "mask"') do set mask=%%j for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "gateway"') do set gw=%%j for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "dns1"') do set dns1=%%j for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "dns2"') do set dns2=%%j :_inspect1 if %ip%=="" (set err=无法从文件中获取与MAC地址相对应的IP地址,请检查mac.txt文件的完整性 && goto _error) :_hostname for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "每段最大IP数"') do set dw=%%j for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "开始段位"') do set ks=%%j for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "excursion"') do set excursion=%%j for /f "eol=# tokens=2,3* delims=." %%a in ('echo %ip%') do (set /a num=%%c+%%b*%dw%-%dw%*%ks%+% excursion%) for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "prefix"') do set prefix=%%j for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "机号位数"') do set ws=%%j set name=00000%num% set name=!name:~-%ws%! goto _setup :_setup reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d %prefix%%name% /f reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %prefix%%name% /f reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %prefix%%name% /f reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NwlnkIpx\Parameters" /v VirtualNetworkNumber /t reg_dword /d %num% /f netsh interface ip set address name="本地连接" source=static addr=%ip% mask=%MASK% netsh interface ip set address name="本地连接" gateway=%gw% gwmetric=0 netsh interface ip set dns name="本地连接" source=static addr=%dns1% register=PRIMARY netsh interface ip add dns name="本地连接" addr=%DNS2% index=2 :_print for /f "tokens=1* delims=:" %%i in ('ipconfig /all^|find /i "IP Address"') do set ip=%%j for /f "tokens=1* delims=:" %%i in ('ipconfig /all^|find /i "Physical Address"') do set mac=%%j for /f "tokens=1* delims=:" %%i in ('ipconfig /all^|find /i "Subnet Mask"') do set mask=%%j for /f "tokens=1* delims=:" %%i in ('ipconfig /all^|find /i "Default Gateway"') do set gw=%%j echo Tools Name: daker's ipconfig tool>%temp%\print.txt echo Author: Daker>>%temp%\print.txt echo Version:1.2>>%temp%\print.txt echo tel:13991925859>>%temp%\print.txt echo e-mail:daker@126.com>>%temp%\print.txt echo ##########################>>%temp%\print.txt echo hostname:sa-%name%>>%temp%\print.txt echo ip:%ip%>>%temp%\print.txt echo mac:%mac%>>%temp%\print.txt echo ntemask:%mask%>>%temp%\print.txt echo gateway:%gw%>>%temp%\print.txt echo dns:%dns1%,%dns2%>>%temp%\print.txt echo ##########################>>%temp%\print.txt start %temp%\print.txt :_delete set ip= set mac= set gw= set dns1= set dns2= set name= set num= set n3= set excursion= set prefix= for /f "eol=# tokens=1* delims=:" %%i in ('type address.ini^|find /i "delete"') do set onff=%%j if %onff%==y (reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v ipaddress /f) del "%temp%"\*.bat /ah /q & exit :_error mshta vbscript:CreateObject("Wscript.Shell").popup("%err% ",10,"错误提示",64)(window.close)
#子网掩码 mask:255.255.255.0 #网关 gateway:192.168.0.1 #主DNS dns1:218.30.19.40 #辅DNS dns2:61.134.1.4 #每个使用段位的最大IP数量 每段最大IP数:254 #即192.168.X.100 X为0就写0,为100就写100 开始段位:0 #如sa-001 就为3 sa-0001就为4 机号位数:3 #机号与IP偏移值,此值不能为空,如无偏移请填写0。 excursion:-10 #机器名称前缀 prefix:sa- #是否开机执行一次后删除自启动项目 delete:n
192.168.0.1 00-00-00-00-00-00 192.168.0.2 11-11-11-11-11-11