复制代码
- @ECHO OFF
- @cls
- ECHO ::::::::::::::::::::::::::::::::::::::::::::::::::::
- ECHO :: GHOST完成后根据网卡MAC自动设置机名和IP的批处理 ::
- ECHO ::::::::::::::::::::::::::::::::::::::::::::::::::::
- ::::清空环境变量
- Set IPAddress=
- Set strMac=
- Set MacAddress=
- Set CName=
- Set scfile=
- Set sc=
- Set MacWMIC=
- Set ConnName=
- cd/d %temp%
- REM ::::请手动修改列表
- ECHO [ComputerName] [MacAddress] [IPAddress] >iplist.txt
- echo a02 00-04-61-4D-AA-1A 172.30.10.2 >>iplist.txt
- echo a03 00-04-61-4D-C8-78 172.30.10.3 >>iplist.txt
- echo a04 00-04-61-4D-C9-F7 172.30.10.4 >>iplist.txt
- echo a05 00-04-61-4D-C6-EE 172.30.10.5 >>iplist.txt
- echo a06 00-04-61-4E-24-68 172.30.10.6 >>iplist.txt
- echo a07 00-04-61-4D-B1-B7 172.30.10.7 >>iplist.txt
- echo a08 00-04-61-4D-B5-F6 172.30.10.8 >>iplist.txt
- echo a09 00-04-61-4E-24-6E 172.30.10.9 >>iplist.txt
- echo a10 00-04-61-4E-24-BF 172.30.10.10 >>iplist.txt
- echo a11 00-04-61-4D-C6-EF 172.30.10.11 >>iplist.txt
- echo a12 00-04-61-4D-C5-08 172.30.10.12 >>iplist.txt
- echo a13 00-04-61-48-16-C9 172.30.10.13 >>iplist.txt
- echo a14 00-04-61-4E-29-B9 172.30.10.14 >>iplist.txt
- echo a15 00-04-61-4E-2A-20 172.30.10.15 >>iplist.txt
- echo a16 00-04-61-4E-2A-4C 172.30.10.16 >>iplist.txt
- echo a17 00-04-61-4D-AF-D1 172.30.10.17 >>iplist.txt
- echo a18 00-04-61-4D-C9-F8 172.30.10.18 >>iplist.txt
- echo a19 00-04-61-4E-21-05 172.30.10.19 >>iplist.txt
- echo a20 00-04-61-48-16-C8 172.30.10.20 >>iplist.txt
- echo a21 00-04-61-4E-25-81 172.30.10.21 >>iplist.txt
- echo a22 00-04-61-4D-C6-DD 172.30.10.22 >>iplist.txt
- echo a23 00-04-61-4D-C5-7C 172.30.10.23 >>iplist.txt
- echo a24 00-04-61-4D-C9-AE 172.30.10.24 >>iplist.txt
- echo a25 00-04-61-4D-C5-7A 172.30.10.25 >>iplist.txt
- echo a26 00-04-61-4D-C5-06 172.30.10.26 >>iplist.txt
- echo a27 00-04-61-48-16-C7 172.30.10.27 >>iplist.txt
- echo a28 00-04-61-4D-C5-73 172.30.10.28 >>iplist.txt
- echo a29 00-04-61-4D-AF-45 172.30.10.29 >>iplist.txt
- echo a30 00-04-61-4E-34-B8 172.30.10.30 >>iplist.txt
- echo a31 00-04-61-4E-34-B9 172.30.10.31 >>iplist.txt
- echo a32 00-04-61-4D-B6-27 172.30.10.32 >>iplist.txt
- echo a33 00-04-61-4D-C1-5C 172.30.10.33 >>iplist.txt
- echo a34 00-04-61-4D-C5-3E 172.30.10.34 >>iplist.txt
- echo a35 00-04-61-4D-C1-36 172.30.10.35 >>iplist.txt
- echo a36 00-04-61-49-2F-8E 172.30.10.36 >>iplist.txt
- echo a37 00-04-61-4D-B5-CD 172.30.10.37 >>iplist.txt
- echo a38 00-04-61-4D-B5-F3 172.30.10.38 >>iplist.txt
- echo a39 00-04-61-4D-B6-32 172.30.10.39 >>iplist.txt
- echo a40 00-04-61-4D-AA-18 172.30.10.40 >>iplist.txt
- echo a41 00-04-61-4D-BB-4D 172.30.10.41 >>iplist.txt
- echo a42 00-04-61-4E-24-BE 172.30.10.42 >>iplist.txt
- echo a43 00-04-61-49-1E-41 172.30.10.43 >>iplist.txt
- echo a44 00-04-61-4D-C1-2D 172.30.10.44 >>iplist.txt
- echo a45 00-04-61-4D-C8-7B 172.30.10.45 >>iplist.txt
- echo a46 00-04-61-4E-25-75 172.30.10.46 >>iplist.txt
- echo a47 00-04-61-4D-C9-D4 172.30.10.47 >>iplist.txt
- echo a48 00-04-61-4D-C8-92 172.30.10.48 >>iplist.txt
- echo a49 00-04-61-4E-25-19 172.30.10.49 >>iplist.txt
- echo a50 00-04-61-4D-C9-F0 172.30.10.50 >>iplist.txt
- echo a51 00-04-61-4E-25-58 172.30.10.51 >>iplist.txt
- echo a52 00-04-61-49-10-3E 172.30.10.52 >>iplist.txt
- echo a53 00-04-61-4D-C8-B4 172.30.10.53 >>iplist.txt
- echo a54 00-04-61-4D-C8-83 172.30.10.54 >>iplist.txt
- echo a55 00-04-61-4E-27-B0 172.30.10.55 >>iplist.txt
- echo a56 00-04-61-4D-C1-3C 172.30.10.56 >>iplist.txt
- echo a57 00-04-61-4D-BB-4E 172.30.10.57 >>iplist.txt
- echo a58 00-04-61-4D-C8-33 172.30.10.58 >>iplist.txt
- echo b01 00-04-61-4E-28-03 172.30.10.101 >>iplist.txt
- echo b02 00-04-61-4E-24-EE 172.30.10.102 >>iplist.txt
- echo b03 00-04-61-4D-C8-C8 172.30.10.103 >>iplist.txt
- echo b04 00-04-61-4D-CA-1A 172.30.10.104 >>iplist.txt
- echo b05 00-04-61-4E-25-2C 172.30.10.105 >>iplist.txt
- echo b06 00-00-00-00-00-00 172.30.10.106 >>iplist.txt
- echo b07 00-04-61-4E-28-04 172.30.10.107 >>iplist.txt
- echo b08 00-04-61-4D-BB-5B 172.30.10.108 >>iplist.txt
- echo b09 00-04-61-4D-B5-4A 172.30.10.109 >>iplist.txt
- echo b10 00-04-61-4D-C6-E3 172.30.10.110 >>iplist.txt
- echo b11 00-04-61-49-1F-F8 172.30.10.111 >>iplist.txt
- echo b12 00-00-00-00-00-00 172.30.10.112 >>iplist.txt
- echo b13 00-04-61-4D-AF-6F 172.30.10.113 >>iplist.txt
- echo b14 00-04-61-4D-C8-49 172.30.10.114 >>iplist.txt
- echo b15 00-04-61-4E-2B-1A 172.30.10.115 >>iplist.txt
- echo b16 00-04-61-4D-B1-9A 172.30.10.116 >>iplist.txt
- echo b17 00-04-61-4E-32-A2 172.30.10.117 >>iplist.txt
- echo b18 00-04-61-4D-C1-56 172.30.10.118 >>iplist.txt
- echo b19 00-04-61-4D-BB-53 172.30.10.119 >>iplist.txt
- echo b20 00-04-61-4E-25-84 172.30.10.120 >>iplist.txt
- echo b21 00-04-61-49-36-D8 172.30.10.121 >>iplist.txt
- echo b22 00-04-61-4D-C6-CE 172.30.10.122 >>iplist.txt
- echo b23 00-04-61-4D-C6-CD 172.30.10.123 >>iplist.txt
- echo b24 00-04-61-4E-27-CB 172.30.10.124 >>iplist.txt
- echo b25 00-04-61-4E-25-57 172.30.10.125 >>iplist.txt
- echo b26 00-04-61-4D-C9-D1 172.30.10.126 >>iplist.txt
- echo b27 00-04-61-4E-2B-11 172.30.10.127 >>iplist.txt
- echo b28 00-04-61-4D-CA-15 172.30.10.128 >>iplist.txt
- echo b29 00-04-61-4E-27-D3 172.30.10.129 >>iplist.txt
- echo b30 00-04-61-4E-24-F1 172.30.10.130 >>iplist.txt
- echo b31 00-04-61-4D-C6-E4 172.30.10.131 >>iplist.txt
- echo b32 00-04-61-4D-C1-3B 172.30.10.132 >>iplist.txt
- echo b33 00-04-61-4D-B5-D5 172.30.10.133 >>iplist.txt
- echo b34 00-04-61-4E-2B-18 172.30.10.134 >>iplist.txt
- echo b35 00-04-61-4D-BB-52 172.30.10.135 >>iplist.txt
- echo b36 00-04-61-4E-29-B3 172.30.10.136 >>iplist.txt
- echo b37 00-04-61-4D-C5-79 172.30.10.137 >>iplist.txt
- echo b38 00-04-61-4E-24-EF 172.30.10.138 >>iplist.txt
- echo b39 00-04-61-4E-32-B8 172.30.10.139 >>iplist.txt
- echo b40 00-00-00-00-00-00 172.30.10.140 >>iplist.txt
- echo b41 00-04-61-4D-AF-D0 172.30.10.141 >>iplist.txt
- echo b42 00-04-61-4E-25-45 172.30.10.142 >>iplist.txt
- echo b43 00-04-61-4D-BB-54 172.30.10.143 >>iplist.txt
- echo b44 00-04-61-4E-2A-1B 172.30.10.144 >>iplist.txt
- echo b45 00-04-61-4D-C5-3D 172.30.10.145 >>iplist.txt
- echo b46 00-04-61-4D-BB-4B 172.30.10.146 >>iplist.txt
- echo b47 00-04-61-4D-C9-9C 172.30.10.147 >>iplist.txt
- echo b48 00-04-61-4E-29-F2 172.30.10.148 >>iplist.txt
- echo b49 00-04-61-4D-BB-5D 172.30.10.149 >>iplist.txt
- echo b50 00-04-61-4E-24-6D 172.30.10.150 >>iplist.txt
- echo b51 00-04-61-4E-2A-55 172.30.10.151 >>iplist.txt
- echo b52 00-04-61-49-23-07 172.30.10.152 >>iplist.txt
- echo b53 00-04-61-4E-28-06 172.30.10.153 >>iplist.txt
- echo b52 00-00-00-00-00-00 172.30.10.152 >>iplist.txt
- echo b55 00-04-61-4E-27-CA 172.30.10.155 >>iplist.txt
- echo b56 00-04-61-4E-25-59 172.30.10.156 >>iplist.txt
- echo b57 00-00-00-00-00-00 172.30.10.157 >>iplist.txt
- echo b58 00-04-61-4D-C5-3F 172.30.10.158 >>iplist.txt
- echo b59 00-04-61-4D-AF-C1 172.30.10.159 >>iplist.txt
- echo e01 00-E0-61-03-62-6D 172.30.10.201 >>iplist.txt
- echo e02 00-E0-61-03-57-10 172.30.10.202 >>iplist.txt
- echo e03 00-E0-61-03-5B-66 172.30.10.203 >>iplist.txt
- echo e04 00-E0-61-03-6F-9D 172.30.10.204 >>iplist.txt
- echo e05 00-E0-61-03-6A-F0 172.30.10.205 >>iplist.txt
- echo e06 00-E0-61-03-58-1D 172.30.10.206 >>iplist.txt
- echo e07 00-E0-61-03-58-D2 172.30.10.207 >>iplist.txt
- echo e08 00-E0-61-03-57-74 172.30.10.208 >>iplist.txt
- echo e09 00-E0-61-03-5F-21 172.30.10.209 >>iplist.txt
- echo e10 00-E0-61-03-6F-9B 172.30.10.210 >>iplist.txt
- echo e11 00-E0-61-02-B3-61 172.30.10.211 >>iplist.txt
- echo e12 00-E0-61-03-5B-67 172.30.10.212 >>iplist.txt
- echo e13 00-E0-61-02-B4-80 172.30.10.213 >>iplist.txt
- echo e14 00-E0-61-03-64-FA 172.30.10.214 >>iplist.txt
- echo e15 00-E0-61-03-55-00 172.30.10.215 >>iplist.txt
- echo e16 00-E0-61-03-75-7C 172.30.10.216 >>iplist.txt
- echo e17 00-E0-61-03-68-37 172.30.10.217 >>iplist.txt
- echo e18 00-E0-61-03-64-CC 172.30.10.218 >>iplist.txt
- echo e19 00-E0-61-03-5F-C6 172.30.10.219 >>iplist.txt
- echo e20 00-E0-61-03-5E-95 172.30.10.220 >>iplist.txt
- echo e21 00-E0-61-03-6C-D6 172.30.10.221 >>iplist.txt
- echo e22 00-00-00-00-00-00 172.30.10.222 >>iplist.txt
- echo e23 00-E0-61-03-6E-DA 172.30.10.223 >>iplist.txt
- echo e24 00-E0-61-03-53-0B 172.30.10.224 >>iplist.txt
- echo e25 00-E0-61-03-76-90 172.30.10.225 >>iplist.txt
- echo e26 00-E0-61-02-B2-90 172.30.10.226 >>iplist.txt
- echo e27 00-E0-61-03-72-1A 172.30.10.227 >>iplist.txt
- echo e28 00-E0-61-03-64-CA 172.30.10.228 >>iplist.txt
- echo e29 00-E0-61-03-58-DA 172.30.10.229 >>iplist.txt
- echo e30 00-E0-61-02-B3-67 172.30.10.230 >>iplist.txt
- echo e31 00-00-00-00-00-00 172.30.10.231 >>iplist.txt
- echo e32 00-E0-61-03-5F-26 172.30.10.232 >>iplist.txt
- echo e33 00-E0-61-03-58-3A 172.30.10.233 >>iplist.txt
- echo e34 00-E0-61-03-74-89 172.30.10.234 >>iplist.txt
- echo e35 00-E0-61-03-5B-57 172.30.10.235 >>iplist.txt
- echo e36 00-E0-61-03-58-24 172.30.10.236 >>iplist.txt
- echo e37 00-E0-61-03-68-33 172.30.10.237 >>iplist.txt
- echo e38 00-E0-61-03-68-35 172.30.10.238 >>iplist.txt
- echo e39 00-E0-61-03-5F-04 172.30.10.239 >>iplist.txt
- echo e40 00-E0-61-03-5E-91 172.30.10.240 >>iplist.txt
- echo e41 00-E0-61-03-6D-B3 172.30.10.241 >>iplist.txt
- echo e42 00-E0-61-03-58-22 172.30.10.242 >>iplist.txt
- echo e43 00-E0-61-0B-55-52 172.30.10.243 >>iplist.txt
- echo e44 00-E0-61-03-67-90 172.30.10.244 >>iplist.txt
- echo e45 00-E0-61-03-62-3D 172.30.10.245 >>iplist.txt
- echo e46 00-E0-61-03-76-91 172.30.10.246 >>iplist.txt
- echo e47 00-E0-61-03-71-3F 172.30.10.247 >>iplist.txt
- echo e48 00-E0-61-03-58-1C 172.30.10.248 >>iplist.txt
- echo e49 00-00-00-00-00-00 172.30.10.249 >>iplist.txt
- echo e50 00-E0-61-03-53-0A 172.30.10.250 >>iplist.txt
- echo e51 00-00-00-00-00-00 172.30.10.251 >>iplist.txt
- echo e52 00-E0-61-03-24-5F 172.30.10.252 >>iplist.txt
- echo e53 00-E0-61-03-58-CF 172.30.10.253 >>iplist.txt
- echo e54 00-E0-61-02-B3-65 172.30.10.254 >>iplist.txt
- echo e55 00-E0-61-03-69-D5 172.30.10.199 >>iplist.txt
- echo ead 00-E0-61-03-6E-D6 172.30.10.200 >>iplist.txt
- REM ::::请手动修改子网掩码
- Set mask=255.255.255.0
- REM ::::请手动修改默认网关
- Set gway=172.30.10.1
- ECHO :::: 开始查找网卡 ::::
- ::::获取机器的TCP/IP 配置
- if exist ipconfig.txt del ipconfig.txt
- ipconfig /all >ipconfig.txt
- ::::分离出机器的物理地址,并保存到 ( phyaddr.txt) 文件中
- if exist phyaddr.txt del phyaddr.txt
- if exist phyaddr1.txt del phyaddr1.txt
- find "Physical Address" ipconfig.txt >phyaddr.txt
- Set sc=1
- Set scfile=phyaddr.txt
- goto scan
- ::::多网卡时,扫描每个网卡MAC地址
- :rescan1
- Set sc=%sc%1
- Set scfile=phyaddr1.txt
- find /v "%strMac%" phyaddr.txt >%scfile%
- Goto scan
- :rescan2
- Set sc=%sc%1
- Set scfile=phyaddr.txt
- find /v "%strMac%" phyaddr1.txt >%scfile%
- Goto scan
- :scan
- ::::从(c:\phyaddr.txt)文件中取得物理地址字符串,并赋给变量"MacAddress"
- for /f "skip=2 tokens=12" %%M in (%scfile%) do set strMac=%%M
- ::::以变量"strMac"为关键字搜索(iplist.txt)中相同的字符串行,并保存到(PCCfg.txt)
- find "%strMac%" iplist.txt >PCCfg.txt
- ::::找出机器名(从"PCCfg.txt"中分离出 机器名字段,并赋给变量"CName")
- for /f "skip=2 tokens=1" %%N in (PCCfg.txt) do set CName=%%N
- if not "%CName%"=="" Goto found
- ::::支持最多扫描5个网卡
- If "%sc%"=="11111" Goto failed
- If "%sc%"=="1" Goto rescan1
- if %scfile%==phyaddr.txt Goto rescan1
- if %scfile%==phyaddr1.txt Goto rescan2
- :found
- ECHO 本机 MAC: %strMac%
- ECHO 目标名称: %CName%
- ::::显示IP地址. (从"PCCfg.txt"中分离出 IP地址字段,并赋给变量"IPAddress")
- for /f "skip=2 tokens=3" %%I in (PCCfg.txt) do set IPAddress=%%I
- ECHO 目标地址: %IPAddress%
- ::::显示网卡MAC地址.(从"PCCfg.txt"中分离出 MAC地址字段,并赋给变量"MacAddress")
- for /f "skip=2 tokens=2" %%M in (PCCfg.txt) do set MacAddress=%%M
- ECHO 目标 MAC: %MacAddress%
- ::::创建注册表文件
- ::::用变量"%CName%"去替换实际的机器名
- ECHO Windows Registry Editor Version 5.00 >PCName.reg
- ECHO.>>PCName.reg
- ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName] >>PCName.reg
- ECHO "ComputerName"="%CName%" >>PCName.reg
- ECHO.>>PCName.reg
- ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] >>PCName.reg
- ECHO "NV Hostname"="%CName%" >>PCName.reg
- ECHO "Hostname"="%CName%" >>PCName.reg
- ECHO :::: 正在更改设置 ::::
- REM 导入注册表文件。用的时候把" :: "去掉
- regedit /s PCName.reg
- REM 修改IP地址。用的时候把" :: "去掉
- netsh interface ip set address name="本地连接" source=static addr=%IPAddress% mask=%mask% gateway=%gway% gwmetric=1
- netsh interface ip set dns "本地连接" static 202.96.64.68
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |