A-A+
系统崩溃或硬盘坏道进不去系统,如何怎么知道系统里原来的IP地址配置信息?
本文批处理代码适用于系统崩溃或者硬盘坏道,导致原系统进不去,只能进PE系统重装系统,但又想保存原系统里的IP地址的设置,就可以用这个批处理在PE里导出原系统的IP地址
本文批处理代码适用里一些固定IP地址的电脑,比如服务器、企事业单位等电脑
将下列文件保存为IP.bat就可以了。
@echo off REM @echo off 2>nul 3>nul setlocal enabledelayedexpansion ::判断当前已使用盘符及系统WINDOWS盘符 set a=C D E F G H I J K L M N O P Q R S T U V W X Y Z set dr= echo 当前已使用盘符有: for %%i in (%a%) do if exist %%i: echo %%i: echo. =============================================================== echo. echo 当前WINDOWS系统盘符为: for %%t in (software) do ( for %%j in (%a%) do if exist "%%j:\Windows\System32\config\%%t" ( if %%j: neq %SystemDrive% echo %%j: & set dr=%%j )) set input=%dr% echo. echo. =============================================================== ::PE系统中显示原WINDOWS系统IP信息 set /p Input=↑↑↑根据上面列出的WINDOWS系统盘符输入要查询的系统安装盘符【如:%dr%】: if %Input%=="" set Input="C" echo 当前输入的盘符是:%Input% echo. echo. 将在当前文件夹下创建:Tmp-IP.txt,以备查。 echo. Pause if /i "%Input%:" neq "%systemDrive%" ( for %%a in (software system) do ( if not exist "%Input%:\Windows\System32\config\%%a" echo,输错啦&pause & exit/b ) 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 "" "%TEMP%\IPInfo.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 (for /f "tokens=1,2*" %%a in ('reg query "HKLM\%2\%v3%"') do ( if /i "%%a" == "Domain" ( if "%%c" neq "" (echo,域名名称:%%c)else echo,域名名称:^<nul^> ) else if /i "%%a" == "HostName" echo,主机名称:%%c ))>"%TEMP%\IPInfo.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 地 址:!DHCPIPAddress! echo,子网掩码:!DHCPSubnetMask! echo,默认网关:!DHCPDefaultGateway! echo,DNS 地址:!DHCPNameServer! ) else ( echo,IP 地 址:!IPAddress! echo,子网掩码:!SubnetMask! echo,默认网关:!DefaultGateway! echo,DNS 地址:!NameServer! ) ) echo. echo. MAC信息 echo. ============================================================================== rem getmac /v rem ipconfig /all|find /i "物理地址" rem for /f "tokens=12 delims= " %%i in ('ipconfig /all^|find /i "物理地址"') DO (echo. 物理地址:%%i) for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i /c:"物理地址"') do echo. 物理地址:%%i echo. ============================================================================== echo. 所有网络连接 echo. ============================================================================== ipconfig /all echo. echo. ============================================================================== )>>"%TEMP%\IPInfo.txt" @echo F | xcopy "%TEMP%\IPInfo.txt" .\Tmp-IP.txt /Y /Q >nul