http://user.qzone.qq.com/904505413/blog/1377187294
这个我自己在用,你试试
拨号宽带连接
文件名称:多账号宽带连接拨号批处理脚本
文件类型:windows 批处理
测试系统:WIN7 sp1
已知问题:xp下出现“命令行参数过多”错误提示
核心功能:多账号切换拨号上网
附加功能:多网卡选择、甄别同类型网卡、账号排序、自动挂断已存在的宽带连接、自行使用已存在的宽带名拨号,否则建立临时拨号连接、记录每个账号的上次拨号状态及距今时间、
计划功能:账号信息加密存储、- :::::::::::::::::::::::::::::::自动触发UAC::::::::::::::::::::::::::::::
- @pushd "%temp%"
- @echo.>%systemroot%\testfile.tmp
- @if exist %systemroot%\testfile.tmp goto StartWithAdmin
- @echo Set UAC = CreateObject^("Shell.Application"^)>getadm.vbs
- @echo UAC.ShellExecute "%~0", "%*", "", "runas", 1 >>getadm.vbs
- @getadm.vbs
- @goto :eof
- :StartWithAdmin
- @del %systemroot%\testfile.tmp
- @if exist getadm.vbs del getadm.vbs
- @pushd "%~dp0"
- :::::::::::::::::::::::::::::auto touch UAC:::::::::::::::::::::::::::::
- @echo off
- set 忽略行=340
- cls
- color 07
- set 本文件路径=%0
- set "本文件路径=%本文件路径:"=%"
- set 电话薄=%APPDATA%\Microsoft\Network\Connections\Pbk\rasphone.pbk
- title %本文件路径%
- :mode con: cols=90 lines=30
- echo 初始化网卡设备列表……
- setlocal EnableDelayedExpansion
- :扩展延迟
- set 网卡=0
- rem 扫描所有物理网卡
- FOR /F "usebackq eol= tokens=* delims=:" %%i IN (`reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\PCi /f "Net" /s /e /d`) DO (
- reg query "%%i\Control" 2>nul 1>nul
- IF !ERRORLEVEL! EQU 0 (
- set /a 网卡=!网卡!+1
- set HLM!网卡!=%%i)
- )
- if /i !网卡!==0 echo.未搜索到物理网卡,立即退出。&pause>nul&goto :eof
- rem 确认所有物理网卡类别号
- for /l %%a in (1,1,%网卡%) do (
- call :z HLM %%a Driver Driver HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\
- )
- rem 获取物理网卡唯一型号
- for /l %%a in (1,1,%网卡%) do (
- reg query "!HLM%%a!" /e /f "FriendlyName" >nul
- IF !ERRORLEVEL! EQU 1 (
- call :z Driver %%a DriverDesc FriendlyName
- ) else (
- call :z HLM %%a FriendlyName FriendlyName
- )
- )
- for /l %%a in (1,1,%网卡%) do (
- call :z Driver %%a NetCfgInstanceId NetCfgInstanceId HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\ \Connection
- )
- for /l %%a in (1,1,%网卡%) do (
- call :z NetCfgInstanceId %%a Name Name
- )
- set 账号=0
- echo 初始化账号信息列表……
- call :SJC 现在时间
- ::实现按账号自动排序
- set 列表=%本文件路径%
- if exist mac.txt set 列表=mac.txt&set 忽略行=0
- FOR /F "usebackq eol=; tokens=1,2,3,4,* delims=_ " %%a IN (`"more +%忽略行% "%列表%" | sort /+14"`) DO (
- set /a 账号=!账号!+1
- set MAC!账号!=%%a
- set 户名!账号!=%%b
- set 密码!账号!=%%c
- if [%%e]==[] (set 状态!账号!=-) else (set 状态!账号!=%%e)
- if not [%%d]==[] (
- set /a 差=%现在时间%-%%d
- call :SJC1 差 !差!
- set 描述!账号!=%%d
- set 描述差!账号!=!差!
- )
- )
- if %账号%==0 (
- echo 请手动在本文最后按格式正确添加拨号所需信息后再运行&echo.格式为:mac地址_账号_密码(请用下划线相互隔开)&echo.现在退出
- pause>nul
- goto EOF
- )
- rem 转换成大写字母
- for /l %%r in (1,1,%账号%) do (
- for %%i in (A B C D E F) do call set MAC%%r=%%MAC%%r:%%i=%%i%%
- )
- if %网卡%==1 (
- set "uf=[%Name1%] %FriendlyName1%"
- goto oo
- )
- :123
- cls
- color 72
- for /l %%d in (1,1,%网卡%) do (
- set no= %%d
- set nn=[!Name%%d!]
- echo NO.!no:~-2!:!nn:~0,12!!FriendlyName%%d!
- )
- set xz=
- set /p xz=选择要更改mac的网卡:
- if "%xz%"=="" goto 123
- if /i %xz% leq 0 goto 123
- if /i %xz% gtr %网卡% goto 123
- set uf=[!Name%xz%!] !FriendlyName%xz%!
- :oo
- cls
- color 79
- echo 已选择网卡:(输入0重新选择网卡)
- echo %uf%
- echo ┏━━━┯━━┯━━━┯━━━━━┯━━━━━━━━┓
- echo ┃ 序号 ║状态║ 账号 ║ MAC地址 ║ 上次拨号距今 ┃
- :显示mac.txt预留的mac地址与账号密码
- for /l %%r in (1,1,%账号%) do (
- set no=NO. %%r
- set zz= !状态%%r!
- echo ┃!no:~0,3!!no:~-3!║!zz:~-4!║!户名%%r:~0,2!**!户名%%r:~-2!║!MAC%%r:~0,2!******!MAC%%r:~-2!║!描述差%%r:~-18!┃
- )
- echo ┗━━━┷━━┷━━━┷━━━━━┷━━━━━━━━┛&if not "%xx%"=="" (echo. 上次NO.%xx%:!户名%xx%!) else echo.
- set xx=
- set /p xx=选择账号:
- if "%xx%"=="" goto oo
- if "%xx%"=="0" (
- if %网卡%==1 (
- cls
- title 已自动选择唯一网卡,请直接选择账号!
- goto oo
- )
- else (
- goto 123)
- )
- if /i "%xx%" lss "0" goto oo
- if /i %xx% gtr %账号% goto oo
- cls
- color 70
- rem 设置地址
- FOR /F "usebackq eol=搜 tokens=3 delims= " %%e IN (`reg query "!Driver%xz%!" /e /f "NetworkAddress"`) DO if %%e==!MAC%xx%! goto abc
- reg add "!Driver%xz%!" /v NetworkAddress /d !MAC%xx%! /f >nul
- ::通过禁用再重启网卡刷新新的mac地址
- netsh interface set interface "!Name%xz%!" disable>nul
- title 重启网卡……
- @ping 127.0.0.1 -n 2 >nul
- netsh interface set interface "!Name%xz%!" enable>nul
- title 网卡就绪……
- @ping 127.0.0.1 -n 2 >nul
- ::拨号连接,必须存在.要相同名字的拨号连接,否则出错
- :abc
- title 开始拨号
- rem 如有已建立的拨号连接,则直接使用此宽带连接名拨号
- if exist %电话薄% (
- rasdial /d>nul
- FOR /F "eol= tokens=* delims=" %%a IN (%电话薄%) DO (
- set 连接名=%%a
- echo 使用已存在的!连接名!进行拨号
- set "连接名=!连接名:[=!"
- set "连接名=!连接名:]=!"
- goto y
- )
- ) else (
- echo 建立临时拨号连接!
- call :ff
- set 连接名=临时连接
- set del=1
- goto y
- )
- :y
- rasdial %连接名% !户名%xx%! !密码%xx%! 2>nul 1>nul
- set 状态=%ERRORLEVEL%
- if %del%=1 del /q %电话薄%
- set del=
- call :SJC 时间戳
- set 描述%xx%=%时间戳%
- set 描述差%xx%=%时间戳%
- if /i %状态%==0 (set 状态%xx%=OK) else set 状态%xx%=%状态%
- if exist mac.txt del mac.txt /q
- for /l %%r in (1,1,%账号%) do echo.!MAC%%r!_!户名%%r!_!密码%%r!_!描述%%r!_!状态%%r!>>mac.txt
- title %本文件路径%
- (echo.拨号结果: %%状态%xx%%% &echo.&echo.如需断开临时连接,请使用rasdial /d命令)|msg %username% /w
- goto oo
- exit
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :SJC
- rem 时间戳计算
- for /f "skip=1 tokens=1-9" %%a in ('wmic path win32_utctime ^| findstr .') do set /a m=%%e+9,m%%=12,y=%%i-m/10,t=365*y+y/4-y/100+y/400+(m*306+5)/10+%%a-719469,t=t*86400+%%c*3600+%%d*60+%%g
- set %1=%t%
- goto :eof
- :SJC1
- rem 时间戳换算日期时间
- set sj=%2
- set /a 秒=%sj%%%60
- if %秒%==0 (set 秒= ) else set 秒= %秒%S
- set /a 分=(%sj%%%(60*60))/60
- if %分%==0 (set 分= ) else set 分= %分%M
- set /a 时=%sj%%%(60*60*24)/3600
- if %时%==0 (set 时= ) else set 时= %时%H
- set /a 天=%sj%/86400
- if %天%==0 (set 天= ) else set 天= %天%D
- set %1=%天:~-4%%时:~-4%%分:~-4%%秒:~-4%
- :set %1=%天%%时%%分%%秒%
- goto :eof
- :z
- FOR /F "usebackq eol=搜 tokens=2,* delims= " %%e IN (`reg query "%%%1%2%%" /e /f "%3"`) DO set %4%2=%5%%f%6
- goto :eof
- :ff
- echo.[涓存椂杩炴帴]>%电话薄%
- echo Encoding=1 >>%电话薄%
- echo PBVersion=1 >>%电话薄%
- echo Type=5 >>%电话薄%
- echo AutoLogon=0 >>%电话薄%
- echo UseRasCredentials=0 >>%电话薄%
- echo LowDateTime=-53926832 >>%电话薄%
- echo HighDateTime=30321816 >>%电话薄%
- echo DialParamsUID=5318464 >>%电话薄%
- echo Guid=660225EAA62B9146A81472EEB39E96D2 >>%电话薄%
- echo VpnStrategy=0 >>%电话薄%
- echo ExcludedProtocols=0 >>%电话薄%
- echo LcpExtensions=1 >>%电话薄%
- echo DataEncryption=8 >>%电话薄%
- echo SwCompression=0 >>%电话薄%
- echo NegotiateMultilinkAlways=0 >>%电话薄%
- echo SkipDoubleDialDialog=0 >>%电话薄%
- echo DialMode=0 >>%电话薄%
- echo OverridePref=15 >>%电话薄%
- echo RedialAttempts=3 >>%电话薄%
- echo RedialSeconds=60 >>%电话薄%
- echo IdleDisconnectSeconds=0 >>%电话薄%
- echo RedialOnLinkFailure=1 >>%电话薄%
- echo CallbackMode=0 >>%电话薄%
- echo CustomDialDll= >>%电话薄%
- echo CustomDialFunc= >>%电话薄%
- echo CustomRasDialDll= >>%电话薄%
- echo ForceSecureCompartment=0 >>%电话薄%
- echo DisableIKENameEkuCheck=0 >>%电话薄%
- echo AuthenticateServer=0 >>%电话薄%
- echo ShareMsFilePrint=0 >>%电话薄%
- echo BindMsNetClient=0 >>%电话薄%
- echo SharedPhoneNumbers=0 >>%电话薄%
- echo GlobalDeviceSettings=0 >>%电话薄%
- echo PrerequisiteEntry= >>%电话薄%
- echo PrerequisitePbk= >>%电话薄%
- echo PreferredPort=PPPoE4-0 >>%电话薄%
- echo PreferredDevice=WAN >>%电话薄%
- echo PreferredBps=0 >>%电话薄%
- echo PreferredHwFlow=0 >>%电话薄%
- echo PreferredProtocol=0 >>%电话薄%
- echo PreferredCompression=0 >>%电话薄%
- echo PreferredSpeaker=0 >>%电话薄%
- echo PreferredMdmProtocol=0 >>%电话薄%
- echo PreviewUserPw=1 >>%电话薄%
- echo PreviewDomain=0 >>%电话薄%
- echo PreviewPhoneNumber=0 >>%电话薄%
- echo ShowDialingProgress=1 >>%电话薄%
- echo ShowMonitorIconInTaskBar=1 >>%电话薄%
- echo CustomAuthKey=0 >>%电话薄%
- echo AuthRestrictions=552 >>%电话薄%
- echo IpPrioritizeRemote=1 >>%电话薄%
- echo IpInterfaceMetric=0 >>%电话薄%
- echo IpHeaderCompression=0 >>%电话薄%
- echo IpAddress=0.0.0.0 >>%电话薄%
- echo IpDnsAddress=8.8.8.8 >>%电话薄%
- echo IpDns2Address=114.114.114.114 >>%电话薄%
- echo IpWinsAddress=0.0.0.0 >>%电话薄%
- echo IpWins2Address=0.0.0.0 >>%电话薄%
- echo IpAssign=1 >>%电话薄%
- echo IpNameAssign=2 >>%电话薄%
- echo IpDnsFlags=0 >>%电话薄%
- echo IpNBTFlags=0 >>%电话薄%
- echo TcpWindowSize=0 >>%电话薄%
- echo UseFlags=3 >>%电话薄%
- echo IpSecFlags=0 >>%电话薄%
- echo IpDnsSuffix= >>%电话薄%
- echo Ipv6Assign=1 >>%电话薄%
- echo Ipv6Address=:: >>%电话薄%
- echo Ipv6PrefixLength=0 >>%电话薄%
- echo Ipv6PrioritizeRemote=1 >>%电话薄%
- echo Ipv6InterfaceMetric=0 >>%电话薄%
- echo Ipv6NameAssign=1 >>%电话薄%
- echo Ipv6DnsAddress=:: >>%电话薄%
- echo Ipv6Dns2Address=:: >>%电话薄%
- echo Ipv6Prefix=0000000000000000 >>%电话薄%
- echo Ipv6InterfaceId=0000000000000000 >>%电话薄%
- echo DisableClassBasedDefaultRoute=0 >>%电话薄%
- echo DisableMobility=0 >>%电话薄%
- echo NetworkOutageTime=0 >>%电话薄%
- echo ProvisionType=0 >>%电话薄%
- echo PreSharedKey= >>%电话薄%
- echo NETCOMPONENTS= >>%电话薄%
- echo ms_msclient=0 >>%电话薄%
- echo ms_server=0 >>%电话薄%
- echo MEDIA=rastapi >>%电话薄%
- echo Port=PPPoE4-0 >>%电话薄%
- echo Device=WAN >>%电话薄%
- echo DEVICE=PPPoE >>%电话薄%
- echo PhoneNumber= >>%电话薄%
- echo AreaCode= >>%电话薄%
- echo CountryCode=0 >>%电话薄%
- echo CountryID=0 >>%电话薄%
- echo UseDialingRules=0 >>%电话薄%
- echo Comment= >>%电话薄%
- echo FriendlyName= >>%电话薄%
- echo LastSelectedPhone=0 >>%电话薄%
- echo PromoteAlternates=0 >>%电话薄%
- echo TryNextAlternateOnFail=1 >>%电话薄%
- goto :eof
- ;__mac地址__ _账号_ _密码_ _描述_
复制代码
|