Windows Batch将记录添加到主机文件 [英] Windows Batch to add a record to hosts file

查看:112
本文介绍了Windows Batch将记录添加到主机文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个批处理文件来将记录添加到Windows中的主机文件中,但是我不需要仅文件追加写入,因为我想检查该记录是否已经存在.有可能吗?

I need a batch file to add a record to hosts file in windows, however I do not need just a file append writing because I would like to check if this record is already present. Is it possibile?

推荐答案

type "%SystemRoot%\system32\drivers\etc\hosts" | find "my_record" ||echo my_record>>"%SystemRoot%\system32\drivers\etc\hosts"

尝试此操作.您需要管理员权限才能在主机文件中添加内容

try this.You'll need administrator permissions to add something in hosts file

这篇关于Windows Batch将记录添加到主机文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆