host修复

本文介绍了两种方法,一种是使用管理员权限在cmd中执行命令,另一种是创建并运行批处理文件,详细描述了如何重置DNS、网络代理设置以及清空hosts文件,以实现系统的网络环境管理。
摘要由CSDN通过智能技术生成

方法1

以管理员身份运行cmd输入指令

for /f %P in ('dir %windir%\WinSxS\hosts /b /s') do copy %P %windir%\System32\drivers\etc & echo %P & Notepad %P

再输入a

方法2

1创建一个记事本

2打开记事本

3将下列代码复制进去:

@echo off

CLS

:: 以管理员权限运行

%1 mshta vbscript:createobject("shell.application").shellexecute("%~s0","::","","runas",1)(window.close)&exit

cd /d %~dp0

:: 初始化DNS

echo 重置DNS...

:刷新DNS

ipconfig /flushdns

:: 初始化网络代理

echo 重置网络代理设置...

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f >nul 2>nul

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f >nul 2>nul

echo 网络代理设置已重置

:: 初始化Hosts文件

@echo off

echo 重置hosts文件...

cd %windir%\system32\drivers\etc

echo # Copyright (c) 1993-2009 Microsoft Corp. > hosts

echo # >> hosts

echo # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. >> hosts

echo # >> hosts

echo # This file contains the mappings of IP addresses to host names. Each >> hosts

echo # entry should be kept on an individual line. The IP address should >> hosts

echo # be placed in the first column followed by the corresponding host name. >> hosts

echo # The IP address and the host name should be separated by at least one >> hosts

echo # space. >> hosts

echo # >> hosts

echo # Additionally, comments (such as these) may be inserted on individual >> hosts

echo # lines or following the machine name denoted by a '#' symbol. >> hosts

echo # >> hosts

echo # For example: >> hosts

echo # >> hosts

echo #      102.54.94.97     rhino.acme.com          # source server >> hosts

echo #       38.25.63.10     x.acme.com              # x client host >> hosts

echo 127.0.0.1 localhost >> hosts

ipconfig /flushdns >nul 2>nul

echo Hosts 文件重置成功

:END

echo 按任何一个键退出...

pause >nul

4另存为,修改文件后缀为.bat(看不到后缀的自行搜索),文件编码选择ANSI,文件名自拟

5双击执行

  • 9
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值