This is a mobile optimized page that loads fast, if you want to load the real page, click this text.

Hướng dẫn Cách đặt lại file Hosts về mặc định

baogia2010

Rìu Chiến Bạc
Khi muốn trả file "Hosts" trở về trạng thái mặc định như ban đầu mới cài Windows. Chúng ta làm như sau:

1. Tải về Notepad++ và cài đặt:
- Phím Windows + R > nhập code sau và Enter
Mã:
https://notepad-plus-plus.org/download
- Chọn phiên bản 32bit hoặc 64bit phù hợp PC và tải về
- Cài đặt Notepad++



2. Truy cập thư mục Windows chứa file "hosts" và sao lưu:
- Phím Windows + R > nhập code sau và Enter
Mã:
%windir%\System32\drivers\etc
- Click chuột phải trên file "hosts" > chọn "Edit with Notepad++"
- Thay thế nội dung trong file "hosts" bằng nội dung sau (mẹo: chọn toàn bộ copy & paste)
Mã:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
- Sao lưu file: File > Save as > chọn "Save as type: All types (*.*)" > lưu file trên Desktop > đóng Notepad++



3. Phục hồi file "hosts" trong thư mục Windows:
Mã:
%windir%\System32\drivers\etc
- Mở lại thư mục Windows chứa file "hosts" > đổi tên file "hosts" thành "hosts.old" (chọn Yes khi có bảng UAC xuất hiện)
- Copy file "host" trên Desktop vào thư mục trên (nếu có yêu cầu password Admin thì nhập vào)


Done!
 

baogia2010

Rìu Chiến Bạc
Thêm cách để Sao lưu và Chỉnh sửa hosts file. Mở Command prompt (run as admin): Start > gõ cmd > giữ phím Ctrl+Shift rồi Enter > chọn Yes trên bảng UAC
1. Sao lưu file hosts của hệ thống (cất đâu tùy bạn):
Nhập code sau vào Command prompt và Enter
Mã:
xcopy %systemroot%\system32\drivers\etc\hosts %userprofile%\Desktop\ /c /q /h /r /y
2. Chỉnh sửa file hosts:
Nhập code sau vào Command prompt và Enter
Mã:
Notepad %systemroot%\system32\drivers\etc\hosts
Nhập nội dung cần chỉnh sửa cho file hosts xong > Lưu file hosts "Ctrl+S" (File > Save)
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
Done!
 

Hamano Kaito

Moderator
Ko cần COPY. Ko cần xóa gì hết
Chỉ cần lệnh Type là được rồi sếp
Lưu phần hosts chưa EDIT với tên bất kỳ rồi dùng lệnh Type là xong

VD: Type "*\hosts-goc" >"%systemroot%\system32\drivers\etc\hosts"
*\ là nơi chứa file bạn cần thay thế nó với đường dẫn lưu file đó. Chạy lệnh như quản trị viên để có hiệu lực
---
Hoặc cũng có thể dùng Type Nul và Echo để chép vào Hosts cũng được. Làm như vậy thì ko cần phải tạo tệp thứ 2
1 file lệnh là đủ. Echo đôi khi ko thể nhận dạng các ký tự số học, cho nên hay lỗi khi chép nội dung.
 

baogia2010

Rìu Chiến Bạc
Cảm ơn Hamano. 1 đoạn trích từ OfficeAct và type nul
View hidden content is available for registered users!

Thêm lệnh more
View hidden content is available for registered users!
 
Sửa lần cuối: