China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 00:26
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Search for the HOSTS file and insert lines View 3,629 Replies 16
Original Poster Posted 2006-11-18 05:43 ·  中国 广东 佛山 顺德区 电信
初级用户
Credits 52
Posts 20
Joined 2006-11-04 23:06
19-year member
UID 69588
Gender Male
Status Offline
I want to find the HOSTS file (which may be a hidden file with no extension!) in the c: drive, and insert a line of text (such as "I o U") at the last line.
Grateful to all the experts who helped me! ;)
Floor 2 Posted 2006-11-18 05:59 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
for /f "tokens=*" %%? in ('dir /a-d/s/b c:\hosts') do (>>%%? echo I o U)
Floor 3 Posted 2006-11-18 06:07 ·  中国 广东 佛山 顺德区 电信
初级用户
Credits 52
Posts 20
Joined 2006-11-04 23:06
19-year member
UID 69588
Gender Male
Status Offline
Error:
There should not be tekons=*" at this time
My HOSTS may not be in the root C drive directory, it may be somewhere in the C drive.
Floor 4 Posted 2006-11-18 06:12 ·  中国 江苏 苏州 联通
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
Change to tokens.
If the prompt file is read-only, it's best to handle it with attrib first.
Floor 5 Posted 2006-11-18 06:19 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 6 Posted 2006-11-18 06:24 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by zdh at 2006-11-18 06:07:
Error:
At this time, there should not be tekons=*"
My HOSTS may not be in the root C drive directory, it may be in some place on the C drive.

Sweat, it was written wrong
Floor 7 Posted 2006-11-18 06:25 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 8 Posted 2006-11-18 09:56 ·  中国 河南 商丘 梁园区 电信
初级用户
Credits 45
Posts 14
Joined 2006-09-12 06:06
19-year member
UID 62386
Status Offline
ATTRIB -A -R -H C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
ECHO I o U >> C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
win2003
Floor 9 Posted 2006-11-18 13:34 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline
Want to add domain name resolution in the hosts under drivers\etc!
Floor 10 Posted 2006-11-18 21:29 ·  中国 广东 佛山 顺德区 电信
初级用户
Credits 52
Posts 20
Joined 2006-11-04 23:06
19-year member
UID 69588
Gender Male
Status Offline
Originally posted by tao0610 at 2006-11-18 01:34 AM:
Want to add domain name resolution in the hosts under drivers\etc!

Yeah! Because it's too cumbersome to access with IP addresses in the local area network. It would be best if it could be resolved!
Floor 11 Posted 2006-11-19 15:25 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline
attrib -s -h %systemroot%\system32\drivers\etc\hosts
echo 202.108.22.5 www.baidu.com >> %systemroot%\system32\drivers\etc\hosts
Floor 12 Posted 2006-11-23 07:28
中级用户
★★
DOS之日
Credits 337
Posts 161
Joined 2006-11-04 05:27
19-year member
UID 69523
Gender Male
Status Offline
Learning
for /f %%h in (`echo hxuan`) do for /f %%x in (`echo hxuan`) do if %%h==%%x nul
Floor 13 Posted 2007-04-26 00:55 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
@echo off
rem -----------------------------------------------
rem Powered by Kinglion Software Workroom
rem www.kinglion.org DNS Resolution Setup Program
rem Don't modify this file
rem -----------------------------------------------
if exist %ComSpec% goto nt

:9x
if not exist %windir%\hosts goto win9xgo
if not exist %windir%\hosts.bak goto win9xgo
del %windir%\hosts.bak
ren %windir%\hosts %windir%\hosts.bak

:win9xgo
echo 221.212.188.60 www.kinglion.org >> %windir%\hosts
goto end

:nt
if not exist %windir%\system32\drivers\etc\hosts goto ntgo
if not exist %windir%\system32\drivers\etc\hosts.bak goto ntgo
del %windir%\system32\drivers\etc\hosts.bak
ren %windir%\system32\drivers\etc\hosts %windir%\system32\drivers\etc\hosts.bak

:ntgo
echo 221.212.188.60 www.kinglion.org >> %windir%\system32\drivers\etc\hosts

:end
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
lxmxn +4 2007-04-26 01:23
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 14 Posted 2007-04-26 01:25 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Brother Kinglion, you consider issues very comprehensively.
Floor 15 Posted 2008-09-24 10:03 ·  中国 广东 东莞 电信
新手上路
Credits 6
Posts 4
Joined 2008-09-24 09:17
17-year member
UID 126459
Gender Male
Status Offline
The script on the 13th floor is great, learning
Forum Jump: