经常碰到很多电脑出现系统损坏甚至硬盘损坏导致不能进系统,但系统内设置的IP地址是静态地址。
只要目标系统的注册表文件SOFTWARE和SYSTEM没损坏,就可以用这个批处理在PE里获取到目标系统的IP地址,只需要用到REG.EXE运行后会在批处理所在目录生成一个Ipinfo.txt保存相关信息。
[Asm] 纯文本查看 复制代码 @echo off 2>nul 3>nul
setlocal enabledelayedexpansion
title 获取目标系统IP地址
color 1f
MODE con: COLS=37 LINES=5
:Main
cls
set /p Input=输入目标系统安装盘符[例如D]:
if /i "%Input%:" neq "%systemDrive%" (
for %%a in (software system) do (
if not exist "%Input%:\Windows\System32\config\%%a" echo,输错啦&ping -n 2 127.0.0.1 >nul 2>nul & goto Main
)
set /p beizhu=备注信息:
echo,正在获取IP地址,请稍候……
reg load HKLM\Temp_HIV1 %Input%:\Windows\System32\config\software >nul
reg load HKLM\Temp_HIV2 %Input%:\Windows\System32\config\system >nul
call :GetIPInfo Temp_HIV1 Temp_HIV2
reg unload HKLM\Temp_HIV1 >nul
reg unload HKLM\Temp_HIV2 >nul
) else call :GetIPInfo SOFTWARE SYSTEM
start "" "%~dp0IPInfo.txt" & exit/b
:GetIPInfo
for /f "tokens=1,2*" %%a in ('reg query "HKLM\%2\select"') do (
if /i "%%a" == "Default" set /a x=%%c
)
set "v1=Microsoft\Windows NT\CurrentVersion\NetworkCards"
set "v2=ControlSet00%x%\Control\Network"
set "v3=ControlSet00%x%\services\Tcpip\Parameters"
set "s=EnableDHCP NameServer IPAddress SubnetMask DefaultGateway"
set "s=%s% DHCPNameServer DHCPIPAddress DHCPSubnetMask DHCPDefaultGateway"
for /f "delims=" %%a in ('reg query "HKLM\%1\%v1%"') do (
set "v=%%a"
if "!v:%v1%\=!" neq "!v!" (
set /a n+=1
for /f "tokens=1,2*" %%b in ('reg query "%%a"') do (
if /i "%%b" == "ServiceName" (
set "Guid!n!=%%d"
) else if /i "%%b" == "Description" set "NetCard!n!=%%d"
)
)
)
if not defined n echo,没找到网卡,请确认后重试&pause & exit
echo,信息采集时间:%date% %time%>>"%~dp0IPInfo.txt"
echo,备注信息:%beizhu%>>"%~dp0IPInfo.txt"
(for /f "tokens=1,2*" %%a in ('reg query "HKLM\%2\%v3%"') do (
if /i "%%a" == "Domain" (
if "%%c" neq "" (echo,登陆域名:%%c)else echo,登陆域名:未登陆域
) else if /i "%%a" == "HostName" echo,计算机名:%%c
))>>"%~dp0IPInfo.txt"
for %%a in (%s%) do set "_%%a=1"
(for /l %%a in (1 1 %n%) do (
echo,&echo,网卡名称:!NetCard%%a!
for %%b in (%s%) do set "%%b="
for /f "delims=" %%b in ('reg query "HKLM\%2\%v2%" /s') do (
if defined flag (
for /f "tokens=1,2*" %%c in ("%%b") do (
if /i "%%c" == "Name" echo,连接名称:%%e& set "flag="
)
) else (
set "v=%%b"
for %%c in ("\!Guid%%a!") do if "!v:%%~c=!" neq "!v!" set flag=1
)
)
for /f "tokens=1,2*" %%b in ('reg query "HKLM\%2\%v3%\Interfaces\!Guid%%a!"') do (
if defined _%%b if "%%d" neq "" set "v=%%d" & set "%%b=!v:\0=!"
)
if /i "!EnableDHCP!" == "0x1" (
echo,IP 模 式:动态获取
echo,IP 地 址:!DHCPIPAddress!
echo,子网掩码:!DHCPSubnetMask!
echo,默认网关:!DHCPDefaultGateway!
echo,DNS 地址:!DHCPNameServer!
) else (
echo,IP 模 式:静态设置
echo,IP 地 址:!IPAddress!
echo,子网掩码:!SubnetMask!
echo,默认网关:!DefaultGateway!
echo,DNS 地址:!NameServer!
)
))>>"%~dp0IPInfo.txt"
echo,============================================================>>"%~dp0IPInfo.txt"
获取目标系统IP地址.rar
(1.38 KB, 下载次数: 86)
|