全自动设置机号、IP工具
哈哈,经过我半个月的学习,我的第一大作终于完成了!!!
放上来给网吧界的同事也来分享下,要是大家觉得好用的话,就给小弟加点分当鼓励下喽,嘻嘻:D
如果想要更完善的功能请看:
全自动设置机号、IP、安装冰点改进版(网吧版)
http://www.cn-dos.net/forum/viewthread.php?tid=26870&fpage=7&highlight=&page=2
自动改IP2.0版
http://www.cn-dos.net/forum/viewthread.php?tid=28621&fpage=2
全自动设置机号、IP工具3.0(完整版)
http://www.cn-dos.net/forum/viewthread.php?tid=32490&fpage=4
ip.bat
@set dbg=
@echo %dbg% off&setlocal enabledelayedexpansion
:: code by qasa copyright@qknet 2:16 2007-1-19
title 全自动设置机号、IP工具 作者:qasa
set no_=0
mode con cols=40 lines=10&color fc
for /f "tokens=12 delims= " %%i in ('ipconfig /all^|find /i "Physical Address"') do (
set mac=%%i
set mac=!mac:~0,-1!
)
for /f "tokens=1-3 delims==|" %%j in (MAC.INI) do (
set mac_=%%j
set ip_=%%k
set sm_=%%l
if !mac! equ !mac_! (
call :set_ !mac_! !ip_! !sm_!
set /a no_+=1
)
)
if "!no_!"=="0" (
echo.&echo MAC.ini中没有此机的MAC地址,将发送到工作机上......
echo %date% %time%新发现的MAC地址:>>NewMAC.ini&echo !mac! >>NewMAC.ini
echo.&echo 已经发送到工作机! ! !
)
start shutdown -r -t 40
echo.
set/p zz_= 按Q键退出关机状态:
if /i !zz_! equ q (start shutdown -a)
ping/n 5 127.1>nul
exit /b
:set_
echo %1 %2 %3
set yy_=%3
echo.&echo 正在为%yy_:~1,3%号设置IP、机号...... 请稍候
for /f "tokens=1-4 delims==|" %%e in (DNS.ini) do (
set dns1_=%%e
set dns2_=%%f
set workgate_=%%g
set zwym_=%%h
)
for /l %%w in (1,1,2) do (
netsh interface IP Set Address "本地连接" Static %2 %zwym_% %workgate_% 1 >nul
)
netsh interface IP Set Dns "本地连接" static %dns1_% >nul
netsh interface ip add dns "本地连接" %dns2_% >nul
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName /v "ComputerName" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v "ComputerName" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "Hostname" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "NV Hostname" /t REG_SZ /d %3 /f >nul 2>NUL
echo.&echo 设置完毕
goto :eof
MAC.ini
00-0A-EB-21-A7-EC=192.168.0.5|-005
00-E0-4C-8F-11-4A=192.168.0.6|-006
00-0A-EB-A0-1D-9A=192.168.0.7|-007
00-40-05-14-E7-C9=192.168.0.8|-008
00-0A-EB-A0-1C-7A=192.168.0.9|-009
00-0D-87-F2-03-50=192.168.0.10|-010
00-0D-87-F2-A3-5C=192.168.0.11|-011
DNS.ini
202.96.128.86=202.96.128.186|192.168.0.1|255.255.255.0
根据你实际的要求,修改MAC.ini 和DNS.ini就行.:P
Last edited by qasa on 2007-8-5 at 02:45 PM ]
### Fully Automatic Machine Number and
IP Setting Tool
Haha, after half a month of study, my first big work is finally completed!!!
Put it up to share with colleagues in the internet café industry. If everyone thinks it's useful, give the little brother some points as an encouragement, hehehe :D
For more complete functions, please see:
http://www.cn-dos.net/forum/viewthread.php?tid=26870&fpage=7&highlight=&page=2
Automatic
IP Change Version 2.0
http://www.cn-dos.net/forum/viewthread.php?tid=28621&fpage=2
Fully Automatic Machine Number and
IP Setting Tool Version 3.0 (Full Version)
http://www.cn-dos.net/forum/viewthread.php?tid=32490&fpage=4
ip.bat
@set dbg=
@echo %dbg% off&setlocal enabledelayedexpansion
:: code by qasa copyright@qknet 2:16 2007-1-19
title Fully Automatic Machine Number and IP Setting Tool Author:qasa
set no_=0
mode con cols=40 lines=10&color fc
for /f "tokens=12 delims= " %%i in ('ipconfig /all^|find /i "Physical Address"') do (
set mac=%%i
set mac=!mac:~0,-1!
)
for /f "tokens=1-3 delims==|" %%j in (MAC.INI) do (
set mac_=%%j
set ip_=%%k
set sm_=%%l
if !mac! equ !mac_! (
call :set_ !mac_! !ip_! !sm_!
set /a no_+=1
)
)
if "!no_!"=="0" (
echo.&echo There is no MAC address of this machine in MAC.ini, and it will be sent to the work machine......
echo %date% %time% Newly discovered MAC address:>>NewMAC.ini&echo !mac! >>NewMAC.ini
echo.&echo Has been sent to the work machine! ! !
)
start shutdown -r -t 40
echo.
set/p zz_= Press Q key to exit the shutdown state:
if /i !zz_! equ q (start shutdown -a)
ping/n 5 127.1>nul
exit /b
:set_
echo %1 %2 %3
set yy_=%3
echo.&echo Is setting IP and machine number for %yy_:~1,3% number...... Please wait
for /f "tokens=1-4 delims==|" %%e in (DNS.ini) do (
set dns1_=%%e
set dns2_=%%f
set workgate_=%%g
set zwym_=%%h
)
for /l %%w in (1,1,2) do (
netsh interface IP Set Address "Local Area Connection" Static %2 %zwym_% %workgate_% 1 >nul
)
netsh interface IP Set Dns "Local Area Connection" static %dns1_% >nul
netsh interface ip add dns "Local Area Connection" %dns2_% >nul
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName /v "ComputerName" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v "ComputerName" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "Hostname" /t REG_SZ /d %3 /f >nul 2>NUL
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "NV Hostname" /t REG_SZ /d %3 /f >nul 2>NUL
echo.&echo Setting completed
goto :eof
MAC.ini
00-0A-EB-21-A7-EC=192.168.0.5|-005
00-E0-4C-8F-11-4A=192.168.0.6|-006
00-0A-EB-A0-1D-9A=192.168.0.7|-007
00-40-05-14-E7-C9=192.168.0.8|-008
00-0A-EB-A0-1C-7A=192.168.0.9|-009
00-0D-87-F2-03-50=192.168.0.10|-010
00-0D-87-F2-A3-5C=192.168.0.11|-011
DNS.ini
202.96.128.86=202.96.128.186|192.168.0.1|255.255.255.0
Just modify MAC.ini and DNS.ini according to your actual requirements. :P
Last edited by qasa on 2007-8-5 at 02:45 PM ]