标题: [原创]NETGHOST后机器名IP及CSKEY全自动配置
[打印本页]
作者: 81291895
时间: 2007-11-30 14:10
标题: [原创]NETGHOST后机器名IP及CSKEY全自动配置
此脚本用于局域网(适合网吧)
Syscfg.ini为脚本配置文件
@Echo off
Title 海洋技术俱乐部IP设置工具
Color 4f
If Exist Client.ini Goto Setip
:GetMac
If Not Exist Syscfg.ini Exit
For /f "tokens=2 delims==" %%i in ('Find "网关=" Syscfg.ini') Do Set GW=%%i
For /f "tokens=2 delims==" %%i in ('Find "子网=" Syscfg.ini') Do Set MASK=%%i
For /f "tokens=2 delims==" %%i in ('Find "DNS1=" Syscfg.ini') Do Set DNS1=%%i
For /f "tokens=2 delims==" %%i in ('Find "DNS2=" Syscfg.ini') Do Set DNS2=%%i
Title 生成本机当前网段IP数据库
Mode con cols=46 Lines=10
Ipconfig|find /i "IP Address">local.txt
For /f "tokens=15 delims= " %%a in (local.txt) Do Echo %%a>local.txt
For /f "tokens=1-4 delims=." %%a in (local.txt) Do Set netia=%%a.%%b.%%c
If exist local.txt Del local.txt
Echo [Syscfg]>ipmac.ini
Echo>>ipmac.ini 网关=%GW%
Echo>>ipmac.ini 子网=%MASK%
Echo>>ipmac.ini DNS1=%DNS1%
Echo>>ipmac.ini DNS2=%DNS2%
Echo [计算机] [CS-KEY] [LX-KEY] [IP地址] [Mac地址]>>ipmac.ini
For /l %%x in (1,1,254) Do (
Cls
Echo. ┏━━━━━━━━━━━━━━━━━━━━┓
Echo. ┃ ┃
Echo. ┃ 正在扫描当前网段在线计算机,请稍等... ┃
Echo. ┃ ┃
Echo. ┗━━━━━━━━━━━━━━━━━━━━┛
Echo. 正在探测.[%netia%.%%x]...&Ping -n 1 -w 100 %netia%.%%x|Find /i "Reply from">nul&&(Nbtstat -a %netia%.%%x|Find /i "<00> UNIQUE">nametmp.txt&Nbtstat -a %netia%.%%x|Find /i "MAC Address">mactmp.txt)&&For /f "tokens=1 delims=< " %%u in (nametmp.txt) Do (
For /f "tokens=4 delims= " %%r in (mactmp.txt) Do (
For /f "skip=2 tokens=2 delims==" %%o in ('find /i "CS%%x=" Syscfg.ini') Do (
For /f "skip=2 tokens=2 delims==" %%l in ('find /i "LX%%x=" Syscfg.ini') Do (
Echo %%u %%o %%l %netia%.%%x %%r>>ipmac.ini
)
)
)
)
)
Del *tmp.txt
Echo.
Set /p Client= 是否生成客户端Y/N:
If /i "%Client%" == "Y" (
Md .\Client>nul
Copy ipmac.ini .\Client\Client.ini /y>nul
Copy %0 .\Client\Client.CMD /y>nul
)
If Exist .\Client\Client.CMD Echo>>.\Client\Client.CMD Shutdown -r -t 3
Echo.
If Exist .\Client\Client.CMD Set /p SetCl= 是否设置客户端在下次开机时运行一次Y/N:
If /i "%SetCl%" == "Y" (
Copy .\Client\* %Systemroot%\ /y>nul
Reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v Setip /t Reg_Sz /d "%Systemroot%\Client.CMD" /f>nul
)
Exit
:Setip
Find "[LX-KEY]" Client.ini>nul||Goto GetMac
For /f "tokens=2 delims==" %%i in ('Find "网关=" Client.ini') Do Set Gw=%%i
For /f "tokens=2 delims==" %%i in ('Find "子网=" Client.ini') Do Set MASK=%%i
For /f "tokens=2 delims==" %%i in ('Find "DNS1=" Client.ini') Do Set DNS1=%%i
For /f "tokens=2 delims==" %%i in ('Find "DNS2=" Client.ini') Do Set DNS2=%%i
Mode con cols=46 Lines=11
Title 读取IP数据库设置本机IP
Ping %GW% -n 1>nul
Ipconfig /all|Find /i "Physical Address">mactemp.txt
Ipconfig|find /i "Ethernet adapter">iptemp.txt
For /f "tokens=3,4 delims=: " %%i in (iptemp.txt) Do (
Echo +%%j+|find /i "++">nul&&Set netname=%%i||Set netname=%%i %%j
)
For /f "tokens=12 delims= " %%m in (mactemp.txt) do set strmac=%%m
If exist iptemp.txt del iptemp.txt
If exist mactemp.txt del mactemp.txt
For /f "tokens=1-5 delims=, " %%h in ('find /i "%strmac%" Client.ini') Do (
Set Name=%%h
Set Cskey=%%i
Set Lxkey=%%j
Set Netip=%%k
)
Echo %Name% %Cskey% %Lxkey% %Netip% %netname% %strmac%>info.txt
Title %name% %netip%
Cls
Echo.
Echo. ┏━━━━━━━━━━━━━━━━━━━━┓
Echo. 计算机名: %name%
Echo. IP地址: %netip%
Echo. 子网掩码: %MASK%
Echo. 默认网关: %GW%
Echo. 首选DNS: %DNS1%
Echo. 备用DNS: %DNS2%
Echo. ┗━━━━━━━━━━━━━━━━━━━━┛
Rem Pause>nul|echo. 本机设置如上,请确定无误,按任意键完成设置
Mode con cols=46 Lines=7
Cls
Echo.
Echo. ┏━━━━━━━━━━━━━━━━━━━━┓
Echo. ┃ ┃
Echo. ┃ 正在完成设置,请稍等... ┃
Echo. ┃ ┃
Echo. ┗━━━━━━━━━━━━━━━━━━━━┛
If exist %Systemroot%\net.txt del %Systemroot%\net.txt
Echo pushd interface ip >%Systemroot%\net.txt
Echo set address name="%netname%" source=static addr=%Netip% mask=%mask% >>%Systemroot%\net.txt
Echo set address name="%netname%" gateway=%GW% gwmetric=0 >>%Systemroot%\net.txt
Echo set dns name="%netname%" source=static addr=%dns1% register=PRIMARY >>%Systemroot%\net.txt
Echo add dns name="%netname%" addr=%dns2% index=2 >>%Systemroot%\net.txt
Echo set wins name="%netname%" source=static addr=none >>%Systemroot%\net.txt
Echo popd >>%Systemroot%\net.txt
Reg add HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t reg_sz /d "%name%" /f>nul
Reg add HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName /v ComputerName /t reg_sz /d "%name%" /f>nul
Reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "NV Hostname" /t reg_sz /d "%name%" /f>nul
Reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v Hostname /t reg_sz /d "%name%" /f>nul
Reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultDomainName /t reg_sz /d "%name%" /f>nul
Reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t reg_sz /d "%name%" /f>nul
Reg add HKLM\SOFTWARE\InterServ\Meteor /v Serial /t reg_sz /d "%lxkey%" /f>nul
Reg add HKLM\SOFTWARE\InterServ\Meteor /v sharekey /t reg_sz /d 1 /f>nul
Reg add HKCU\SOFTWARE\Valve\CounterStrike\Settings /v Key /t reg_sz /d "%cskey%" /f>nul
Rem Reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Start /t reg_sz /d "%systemroot%\System32\Root.vbs" /f>nul
Netsh -f %Systemroot%\net.txt
If exist %Systemroot%\net.txt del %Systemroot%\net.txt
Title 设置完毕,请重启
Cls
Echo.
Echo. ┏━━━━━━━━━━━━━━━━━━━━┓
Echo. ┃ ┃
Echo. ┃ 所有设置均已完成,请重启计算机 ┃
Echo. ┃ ┃
Echo. ┗━━━━━━━━━━━━━━━━━━━━┛
Rem Pause>nul|echo. 按任意键执行重启
Sc config Dhcp start= Disabled
Sc config Dnscache start= Disabled
Rem If exist %systemroot%\system32\Seartcy.dat del /q %systemroot%\system32\server.dat
Rem If exist %systemroot%\system32\Seartcy.dat rename %systemroot%\system32\Seartcy.dat server.dat
附件传不了,郁闷
Syscfg.ini格式如下
[Syscfg]
网关=192.168.0.253
子网=255.255.255.0
DNS1=192.168.0.253
DNS2=61.153.177.196
[CS1.5-cdKey]
CS1=3832845609762
CS2=5899430794142
CS3=5531764511342
CS4=..
.
CS256=1509899106786
[LX-CDKey]
LX1=1c7fc8cbc22a2f
LX2=19654494997df4
LX3=abca5be7b61c56
LX4=a600cfde43503a
.
LX256=1c7fc8cbc22a2f
[
Last edited by 81291895 on 2007-12-1 at 01:19 AM ]
作者: sqwxd
时间: 2009-9-10 00:16
谢谢分享~~~
支持!!!