因为有些精简版系统精简了些文件,无法使用ipconfig来查询或netsh来设置,又因为通过ipconfig、netsh、wmic取出的设置在未接网线情况下无法得到结果,所以自己写了这个批。 其中引用到的sys_cmd.exe是我集合的一个包,里面含adsl.exe是Dialupass.exe 更名的,需要的朋友自己到网上去下载,还原部分的宽带连接是抄的代码了,不是我做的。
备份:-
- @echo off
- setlocal enabledelayedexpansion
- cd /d D:\我的文档\系统设置\驱动备份
- set run=%~dp0
- copy %run%\data\sys_cmd.bat c:\sys_cmd.exe >nul 2>nul
- c:\sys_cmd.exe
- del c:\sys_cmd.exe >nul 2>nul
- c:\windows\systemxx\adsl /allusers /stext "temp.txt"
- for /f "tokens=2 delims=:" %%i in ('type temp.txt^|find "链接名称"') do set linkname=%%i
- for /f "tokens=2 delims=:" %%i in ('type temp.txt^|find "用户名称"') do set uname=%%i
- for /f "tokens=2 delims=:" %%i in ('type temp.txt^|find "口令 "') do set upass=%%i
- set linkname=%linkname:~1,99%
- set uname=%uname:~1,99%
- set upass=%upass:~1,99%
- :BEGIN
- set i=1
- set str=0
- for /f "skip=3 delims=" %%j in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}" /s ') do (
- set str=%%j
- set str=!str:HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\=!
- set str="!str:&=!"
- set str=!str:"=!
- set str=!str: =!
- set n=!str:}=!
- set j=!str:~0,-1!
- rem ECHO 末尾判断:“!n!”==“!j!”
- if "!n!"=="!j!" (
- rem echo !n!=!j!
- set doc=!str!
- set netreg=
- for /f "tokens=2 delims=_" %%k in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\!doc!\Connection" /v "Name" 2^>nul') do set netreg=%%k
- if not "!netreg!"=="" (
- set delsp=!netreg:1394=!
- if not "!delsp!"=="!netreg!" set netreg=
- )
- rem echo 从318}\!doc!}\Connection取出名字=“!netreg!”
- if not "!netreg!"=="" (
- set netreg=!netreg:~3,99!
- call :delspace "!netreg!" & set netreg=!delsp!
- rem echo \!doc!\Connection中取出名字=“!netreg!”
- set link!i!=!netreg!
- for /f "skip=1 tokens=3" %%k in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\!doc!\Connection" /v "PnpInstanceID" 2^>nul') do set str="%%k"
- set delsp="!str:&=!"
- call :delspace "!str!"
- rem echo 取:"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\!doc!\Connection" /v "PnpInstanceID"
- set delsp=!delsp:"=!
- set cardid!i!=!delsp!
- set regid!i!=!doc!
- rem echo 导出:reg export "Interfaces\!doc!" "!netreg!.rgn",追加cardid!i!=!delsp!到!netreg!.crd
- del !netreg!.*>nul 2>nul
- echo.!delsp!>!netreg!.crd
- reg export "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\!doc!" "!netreg!.rgn" >nul
- set /a i=!i!+1
- )
- )
- )
- if "!str!"=="0" echo 没找到网络连接。
- :NETLOOPEND
- set /a i=!i!-1
- if not "!link%i%!"=="" echo 已备份“!link%i%!”&goto NETLOOPEND
- if "%linkname%"=="~1,99" (echo 没有找到pppoe拨号) else ren temp.txt adsl.ini
- if not "%linkname%"=="~1,99" echo 从连接%linkname%读取到用户%uname%的密码是%upass%,已备份。
- echo 任务完成,请按任意键退出或直接关闭本窗口。
- rd /q /s c:\windows\systemxx
- :END
- pause>nul
- exit
- :delspace
- set delsp=%~1
- set delsp=%delsp:"=%
- set tmp1=!delsp:~0,1!
- set tmp2=!delsp:~-1!
- if "!tmp1!"==" " set delsp=%delsp:~2,256%&goto delspace
- if "!tmp2!"==" " set delsp=%delsp:~0,-1%&goto delspace
- if "!tmp1!"==" " set delsp=%delsp:~1,256%&goto delspace
- if "!tmp2!"==" " set delsp=%delsp:~0,-1%&goto delspace
- goto :eof
复制代码
|