1 ::请勿轻易修改此文件,以避免不可预知的错误 gwsbhqt@163.com 2 3 @echo off 4 color 0A 5 setlocal enabledelayedexpansion 6 title Network Fault Repair Tool Build20160414 Made By gwsbhqt@163.com 7 8 echo 网络错误修复工具 & echo 如有任何问题请与 gwsbhqt@163.com 联系... & echo. 9 set /p S=继续?(y/n) : 10 if /i %S% EQU y (cls & echo 请稍候... & echo.) else (exit) 11 12 set S=F 13 set str=以管理员身份运行 14 reg query HKUS-1-5-19 >nul 2>nul && set S=T 15 if %S% EQU T (echo %str% √) else (echo %str% × & goto :error) 16 17 set S=F 18 set str=系统支持 19 ver | find " 6" >nul 2>nul && set S=T 20 ver | find " 10" >nul 2>nul && set S=T 21 if %S% EQU T (echo %str% √) else (echo %str% × & goto :error) 22 23 for /l %%i in (1, 1, 6) do ( 24 if %%i EQU 1 set file=sc 25 if %%i EQU 2 set file=reg 26 if %%i EQU 3 set file=ping 27 if %%i EQU 4 set file=netsh 28 if %%i EQU 5 set file=icacls 29 if %%i EQU 6 set file=takeown 30 31 set str=!file!.exe 文件存在 32 if exist %windir%System32!file!.exe (echo !str! √) else (echo !str! × & goto :error) 33 ) 34 35 for /l %%i in (1, 1, 4) do ( 36 if %%i EQU 1 set dir=LogFiles& set name=LogFiles 37 if %%i EQU 2 set dir=LogFilesWMI& set name=WMI 38 if %%i EQU 3 set dir=wbem& set name=wbem 39 if %%i EQU 4 set dir=driversetc& set name=etc 40 41 set S=T 42 set str=获取 !name! 目录所有权 43 takeown /f %windir%System32!dir! /r /d y >nul 2>nul || set S=F 44 icacls %windir%System32!dir! /reset /t /c /q >nul 2>nul || set S=F 45 icacls %windir%System32!dir! /setowner %username% /t /c /q >nul 2>nul || set S=F 46 icacls %windir%System32!dir! /grant:r system:f /t /c /q >nul 2>nul || set S=F 47 icacls %windir%System32!dir! /grant:r everyone:f /t /c /q >nul 2>nul || set S=F 48 icacls %windir%System32!dir! /grant:r %username%:f /t /c /q >nul 2>nul || set S=F 49 icacls %windir%System32!dir! /grant:r administrators:f /t /c /q >nul 2>nul || set S=F 50 if !S! EQU T (echo !str! √) else (call :colour 0C "!str! ×" true) 51 ) 52 53 set S=F 54 set str=删除 Parameters 注册表项 55 echo y | reg delete HKLMSystemCurrentControlSetserviceseventlogParameters >nul 2>nul 56 reg query HKLMSystemCurrentControlSetserviceseventlogParameters >nul 2>nul || set S=T 57 if %S% EQU T (echo %str% √) else (call :colour 0C "!str! ×" true) 58 59 for /l %%i in (1, 1, 17) do ( 60 set str=启动& set sta=RUNNING& set cmd=auto& set cmd2=start 61 if %%i EQU 1 set srv=eventlog& set name=Windows Event Log 62 if %%i EQU 2 set srv=DcomLaunch& set name=DCOM Server Process Launcher 63 if %%i EQU 3 set srv=RpcEptMapper& set name=RPC Endpoint Mapper 64 if %%i EQU 4 set srv=RpcSs& set name=Remote Procedure Call [RPC] 65 if %%i EQU 5 set srv=PlugPlay& set name=Plug and Play 66 if %%i EQU 6 set srv=TapiSrv& set name=Telephony 67 if %%i EQU 7 set srv=BFE& set name=Base Filtering Engine 68 if %%i EQU 8 set srv=IKEEXT& set name=IKE and AuthIP IPsec Keying Modules 69 if %%i EQU 9 set srv=PolicyAgent& set name=IPsec Policy Agent 70 if %%i EQU 10 set srv=nsi& set name=Network Store Interface Service 71 if %%i EQU 11 set srv=Netman& set name=Network Connections 72 if %%i EQU 12 set srv=Winmgmt& set name=Windows Management Instrumentation 73 if %%i EQU 13 set srv=SstpSvc& set name=※Secure Sckoet Tunneling Protocol Service 74 if %%i EQU 14 set srv=RasMan& set name=※Remote Access Connection Manager 75 if %%i EQU 15 set srv=RasAuto& set name=※Remote Access Auto Connection Manager 76 if %%i EQU 16 set srv=RemoteAccess& set name=Routing and Remote Access 77 if %%i EQU 17 set str=禁用& set sta=STOPPED& set cmd=disabled& set cmd2=stop& set srv=SharedAccess& set name=Internet Connection Sharing [ICS] 78 79 set S=F 80 set str2=!name! 服务 81 sc config !srv! start= !cmd! >nul 2>nul 82 sc !cmd2! !srv! >nul 2>nul 83 ping 0 /n 4 >nul 2>nul 84 sc query !srv! | find "!sta!" >nul 2>nul && set S=T 85 if !S! EQU T (echo !str! !str2! √) else (call :colour 0C "!str! !str2! ×" true) 86 ) 87 88 set S=F 89 set str=重置 HOSTS 文件 90 del /f /s /q %windir%System32driversetchosts >nul 2>nul 91 (echo.> %windir%System32driversetchosts) >nul 2>nul && set S=T 92 if !S! EQU T (echo %str% √) else (call :colour 0C "!str! ×" true) 93 94 set S=F 95 set str=设置 DCHP状态 96 netsh interface ip set address name="本地连接" source=static 192.168.1.1 255.255.255.0 192.168.1.1 >nul 2>nul 97 netsh interface ip set address name="本地连接" source=dhcp >nul 2>nul && set S=T 98 if %S% NEQ T (netsh interface ip set address name="以太网" source=static 192.168.1.1 255.255.255.0 192.168.1.1 >nul 2>nul & netsh interface ip set address name="以太网" source=dhcp >nul 2>nul && set S=T) 99 if %S% EQU T (echo %str% √) else (call :colour 0C "%str% ×" T) 100 101 set S=F 102 set str=设置 DNS服务器 103 netsh interface ip set dns "本地连接" static 114.114.114.114 primary >nul 2>nul && netsh interface ip add dns "本地连接" 114.114.115.115 >nul 2>nul && set S=T 104 if %S% NEQ T (netsh interface ip set dns "以太网" static 114.114.114.114 primary >nul 2>nul && netsh interface ip add dns "以太网" 114.114.115.115 >nul 2>nul && set S=T) 105 if %S% EQU T (echo !str! √) else (call :colour 0C "!str! ×" T) 106 107 set S=F 108 set str=重启 网络适配器 109 netsh interface set interface 本地连接 disabled >nul 2>nul && netsh interface set interface 本地连接 enable >nul 2>nul && set S=T 110 if %S% NEQ T (netsh interface set interface 以太网 disabled >nul 2>nul && netsh interface set interface 以太网 enable >nul 2>nul && set S=T) 111 if %S% EQU T (echo !str! √) else (call :colour 0C "!str! ×" T) 112 113 for /l %%i in (1, 1, 8) do ( 114 if %%i EQU 1 set cmd=netsh winsock reset& set str=重置Winsock目录 115 if %%i EQU 2 set cmd=ipconfig /release& set str=释放网络连接 116 if %%i EQU 3 set cmd=ipconfig /renew& set str=更新网络适配器 117 if %%i EQU 4 set cmd=ipconfig /flushdns& set str=清空DNS缓存 118 if %%i EQU 5 set cmd=ipconfig /registerdns& set str=刷新DHCP租约并重新注册DNS 119 if %%i EQU 6 set cmd=nbtstat /r& set str=重新加载远程缓存 120 if %%i EQU 7 set cmd=nbtstat /rr& set str=释放刷新远程缓存 121 if %%i EQU 8 set cmd=arp /d& set str=清空ARP缓存 122 123 set S=F 124 !cmd! >nul 2>nul && set S=T 125 if !S! EQU T (echo !str! √) else (call :colour 0C "!str! ×" T) 126 ) 127 128 echo. & echo 准备倒计时重启... 129 ping 0 /n 6 >nul 2>nul 130 for /l %%i in (10, -1, 1) do ( 131 cls & echo 网络错误修复工具 & echo 如有任何问题请与 gwsbhqt@163.com 联系... & echo. & echo 尝试修复完成,但不保证成功... & echo. & echo 剩余 %%i 秒重启... 132 ping 0 /n 2 >nul 2>nul 133 if %%i EQU 1 cls & shutdown /r /f /t 0 >nul 2>nul & exit 134 ) 135 136 goto :eof 137 :error 138 color 0C & echo. & echo 环境检测异常,修复终止... & pause > nul 139 goto :eof 140 141 goto :eof 142 :colour Attribute String LineFeed 143 pushd "%temp%"&set/p= <nul>"%~2"&findstr /a:%~1 .* "%~2" nul&del "%~2"&popd&if /i "%~3" EQU "T" echo. 144 goto :eof