http://lzhiren.blog.163.com/blog/static/859410420099293145538/
批处理根据MAC地址改计算机名、 IP、掩码、网关、 DNS复制内容到剪贴板
代
码:-----------------------------------------------------------------
--------------------------------------------------------------------
@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=
If not "%1"=="run" Goto setbootcd/d %temp%
REM : : : :请手动修改列表
ECHO [ComputerName] [MacAddress] [IPAddress] >iplist. txt
ECHO LX001 00-04-01-02-09-90 192. 168. 1. 1 >>iplist. txt
ECHO LX002 00-04-01-02-09-91 192. 168. 1.2 >>iplist. txt
ECHO LX003 00-04-01-02-09-92 192. 168. 1.3 >>iplist. txt
ECHO LX004 00-04-01-02-09-93 192. 168. 1.4 >>iplist. txt
ECHO LXASP 00-03-FF-93-39-9F 192. 168.0. 10 >>iplist. txt
REM : : : :请手动修改子网掩码
Set mask=255.255.255.0
REM : : : :请手动修改默认网关
Set gway=192. 168.0. 1
ECHO : : : :开始查找网卡: : : :
: : : :获取机器的TCP/IP配置if exist ipconfig. txt del ipconfig. txtipconfig /all >ipconfig. txt
: : : :分离出机器的物理地址并保存到( phyaddr. txt)文件中if exist phyaddr. txt del phyaddr. txtif exist phyaddr1. txt del phyaddr1. txtfind "Physical Address" ipconfig. txt >phyaddr. txt
Set sc=1
Set scfile=phyaddr. txtgoto scan
: : : :多网卡时扫描每个网卡MAC地址
:rescan1
Set sc=%sc%1
Set scfile=phyaddr1. txtfind /v "%strMac%" phyaddr. txt >%scfile%
Goto scan
:rescan2
Set sc=%sc%1
Set scfile=phyaddr. txtfind /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=%%Nif not "%CName%"=="" Goto found
: : : :支持最多扫描5个网卡
If "%sc%"=="11111" Goto failed
If "%sc%"=="1" Goto rescan1if %scfile%==phyaddr. txt Goto rescan1if %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=%%IECHO 目标地址: %IPAddress%
: : : :显示网卡MAC地址. (从"PCCfg. txt"中分离出MAC地址字段并赋给变量"MacAddress")for /f "skip=2 tokens=2" %%M in (PCCfg. txt) do set MacAddress=%%MECHO 目标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
: : : :找出MAC地址所对应的连接名称for /f "tokens=1,2,3,4,5,6 delims=-" %%A in ("%MacAddress%") do setMacWMIC=%%A:%%B:%%C:%%D:%%E:%%F
WMIC NIC WHERE "MACAddress='%MacWMIC%' AND NetConnectionID!=NULL" GETNetConnectionID /value >phyaddr. txt
WMIC NIC WHERE "MACAddress='%MacWMIC%' AND NetConnectionID!=NULL" GETNetConnectionID /value >phyaddr. txt
Type phyaddr. txt >phyaddr1. txtfor /f "skip=2 tokens=2* delims==" %%A in (phyaddr1. txt) do setConnName=%%A
Echo连接名称: %ConnName%
REM : : : :修改IP地址。用的时候把" : : "去掉netsh interface ip set address name="%ConnName%" source=staticaddr=%IPAddress% mask=%mask% gateway=%gway% gwmetric=1
ECHO : : : :准备重启 : : : :setlocal
: : : :删除临时文件echo [version] > ipdel. infecho signature=$chicago$ >> ipdel. infecho [defaultinstall] >> ipdel. infecho delfiles=delfiles1 >> ipdel. infecho delfiles=delfiles2 >> ipdel. infecho [destinationdirs] >> ipdel. infecho delfiles1=16391 >> ipdel. infecho delfiles2=01 >> ipdel. infecho [delfiles1] >> ipdel. infecho ip. lnk, , , 1 >> ipdel. infecho [delfiles2] >> ipdel. infecho PCCfg. txt, , , 1 >> ipdel. infecho PCName.reg, , , 1 >> ipdel. infecho ipconfig. txt, , , 1 >> ipdel. inf
echo iplist. txt, , , 1 >> ipdel. infecho phyaddr1. txt, , , 1 >> ipdel. infecho phyaddr. txt, , , 1 >> ipdel. inf
RUNDLL32.EXE SETUPAPI.DLL, InstallHinfSection DefaultInstall
128 . \ipdel. infdel ipdel. inf
: : : :准备重启的文件echo [version] > reboot. infecho signature=$chicago$ >> reboot. infecho [defaultinstall] >> reboot. inf
REM : : : :立即重启。用的时候把" : : "去掉
RUNDLL32.EXE SETUPAPI.DLL, InstallHinfSection DefaultInstall
1 . \reboot. infdel reboot. inf
Goto end
:setboot
Echo [Version] >ipstart. inf
Echo Signature="$CHICAGO$" >>ipstart. inf
Echo [DefaultInstall] >>ipstart. inf
Echo UpdateInis = AddLink >>ipstart. inf
Echo [AddLink] >>ipstart. inf
Echo setup. ini, progman.groups, , "group1=""%%16391%%""" >>ipstart. infEcho setup. ini, group1, , """IP"", """"""%%01%%\ip.bat""""run
RUNDLL32.EXE SETUPAPI.DLL, InstallHinfSection DefaultInstall
128 . \ipstart. infdel ipstart. inf
Echo完成在“开始”菜单的“启动”中创建快捷方式。
Echo请在此之后使用GHOST创建此分区的GHO镜像文件。pause
Goto End
:failed
ECHO ! ! ! !查找网卡失败! ! ! !
:end
复制内容到剪贴板
代
码:-----------------------------------------------------------------
---------------------------echo offtitle扫描即将开始 制作color aclsecho.echo
------------------------------------------------------------echo QQ:欢迎交流echo.echo 本批处理是扫描内网IP、MAC地址和计算机名的并自动保存文件TXT文件echo.echo 再利用“自动改IP.bat”实现自动改IP、计算机名、网络号、DNS、 网关等echo.echo 并自动安装冰点将冰点改名为DF.exe,并保存在“自动改IP.bat”同目录下echo.echo 为了扫描到的结果正确请按照正确格式输入echo.echo---------------------PS制作不容易请保留版
权----------------------set /p gateway=请输入内网网关set /p dns1=请输入你的首选DNSset /p dns2=请输入你的备用DNSecho gateway %gateway% >info. txtecho DNS1 %dns1% >>info. txtecho DNS2 %dns2% >>info. txtecho MAC IP 计算机名>>info. txtset rc=0set /p ipq=请输入内网IP的前3位如192. 168.0set /p iph=请输入你要扫描的IP起始段IP的最后一位set /p con1=请输入你要扫描的数量set /a con= %iph%+%con1%
:scanset ip=%ipq%.%iph%ping -n 1 -w 1 %ip% >nul
title正在检测%ip% 制作if %errorlevel% GEQ 1 goto dzfor /f "tokens=1" %%i in ('nbtstat -a %ip% ^ | find /i "UNIQUE" ^ | find/i "00"' ) do set pcname=%%ifor /f "tokens=4" %%i in ('nbtstat -a%ip% ^ | find /i "MAC Address"' ) doset mac=%%iecho %mac% %ip% %pcname% >>info. txtset /a iph=%iph%+1set /a rc=%rc%+1if %iph% GTR %con% goto endgoto scan
:dzecho %ip%不在线无法扫描set /a iph=%iph%+1if %iph% GTR %con% goto endgoto scan
:endtitle扫描完毕 制作echo 扫描完毕! !
@echo共扫描%con%台PC。其中%rc%台PC在线! !pauseecho offfor /f "tokens=2" %%i in ('findstr /r /i "dns1" info. txt' ) do Setdns1=%%ifor /f "tokens=2" %%i in ('findstr /r /i "dns2" info. txt' ) do Setdns2=%%ifor /f "tokens=2" %%i in ('findstr /r /i "gateway" info. txt' ) do Setgateway=%%ifor /f "tokens=2 delims=:" %%i in (' ipconfig /all ^ | find /i "PhysicalAddress"' ) do Set mac=%%ifor /f "tokens=2,3 " %%i in ('findstr /r /i "%mac%" info. txt' ) do setip=%%i & set pcname=%%jfor /f "tokens=4,5 delims=. " %%i in ('findstr /r /i "%mac%" info. txt' )do Set /a netkey=%%i+%%j
: :判断本地连接赋值ljfor /f "tokens=3 delims=: " %%i in (' ipconfig ^ |findstr /r "adapter"' )do set lj=%%i
@echo本地连接名为 %lj%
@echo本机IP为 %ip%
@echo本机计算机名为 %pcname%
@echo本机首选DNS为 %dns1%
@echo本机备用DNS为 %dns2%
@echo 内网网关为 %gateway%
@echo本地网络号为 %netkey%
@echo正在修改IP等信息。 。 。 。ping 127.0.0. 1 -n 2 >nulnetsh interface ip set address name="%lj%" source=static addr=%ip%mask=255.255.255.0 gateway=%gateway% gwmetric=1netsh interface ip set dns name="%lj%" source=static addr=%dns1%netsh interface ip add dns "%lj%" %dns2% index=2
REG add "HKLM\SYSTEM\CurrentControlSet\Services\NwlnkIpx\Parameters"/v VirtualNetworkNumber /t REG_DWORD /d %netkey% /f
: :更改计算机名reg add
"HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /vComputerName /t reg_sz /d %pcname% /f
REG add "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v"Hostname" /t REG_SZ /d %pcname% /f
REG add "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v"NV Hostname" /t REG_SZ /d %pcname% /f
复制内容到剪贴板
代
码:-----------------------------------------------------------------
--------------------------------------------------------------------
---------------------------
@echo offcolor 0asetlocal EnableDelayedExpansiontitle 自动改IP,计算机名,批处理,新东方红网吧专用版by彬set mask=255.255.255.0set gateway=192. 168. 1. 1set DNS1=202.96. 128.86set DNS2=202.96. 128. 166set DNS3=61. 144.56. 100set DNS4=202.96. 128.68echo.
echo. 完成获取资料,请检查正确后按确认键开始执行修改任务echo.for /f "tokens=2 delims=:" %%M in (' ipconfig /all^ |find /i "PhysicalAddress"' ) do set Mac=%%Mecho. 本机MAC地址: %Mac% (硬件获取)set PCMAC=%MAC:~1%echo.for /f "tokens=1" %%a in (' type MAC. ini^ |find /i "%PCMac%"' ) do (setpcname=%%a)echo 本机计算机名: %pcname% (动态获取)echo.for /f "tokens=2" %%b in (' type MAC. ini^ |find /i "%PCMac%"' ) do (setmyip=%%b)echo 本机IP地址: %myip% (动态获取)echo.echo.****************************************************************
*********echo 子网掩码: %mask% (静态获取)echo 本机网关: %gateway% (静态获取)echo. 本机DNS1: %DNS1% (静态获取)echo. 本机DNS2: %DNS2% (静态获取)echo. 本机DNS3: %DNS3% (静态获取)echo. 本机DNS4: %DNS4% (静态获取)echo.pauseecho 修改计算机器名ing. . .reg add"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam" /v@/t REG_SZ /d "%pcname%" /freg add
"HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v"ComputerName" /t REG_SZ /d "%pcname%" /f
Budgetvm(原EZ机房),2005年成立的美国老品牌机房,主打美国4个机房(洛杉矶、芝加哥、达拉斯、迈阿密)和日本东京机房的独立服务器和VPS业务,而且不限制流量,默认提供免费的1800G DDoS防御服务,支持IPv6和IPMI,多种免费中文操作系统可供选择,独立服务器主打大硬盘,多硬盘,大内存,用户可以在后台自行安装系统等管理操作!内存可定制升级到1536G,多块硬盘随时加,14TBSA...
近日CloudCone发布了七月的特价便宜优惠VPS云服务器产品,KVM虚拟架构,性价比最高的为2核心1.5G内存1Gbps带宽5TB月流量,2.89美元/月,稳定性还是非常不错的,有需要国外便宜VPS云服务器的朋友可以关注一下。CloudCone怎么样?CloudCone服务器好不好?CloudCone值不值得购买?CloudCone是一家成立于2017年的美国服务器提供商,国外实力大厂,自己开...
spinservers怎么样?spinservers大硬盘服务器。Spinservers刚刚在美国圣何塞机房补货120台独立服务器,CPU都是双E5系列,64-512GB DDR4内存,超大SSD或NVMe存储,数量有限,机器都是预部署好的,下单即可上架,无需人工干预,有需要的朋友抓紧下单哦。Spinservers是Majestic Hosting Solutions,LLC旗下站点,主营美国独立...