gpt4 book ai didi

batch-file - Windows Batch 将记录添加到主机文件

转载 作者:行者123 更新时间:2023-12-04 17:01:26 30 4
gpt4 key购买 nike

我需要一个批处理文件来向 windows 中的主机文件添加一条记录,但是我不需要只添加文件,因为我想检查该记录是否已经存在。有可能吗?

最佳答案

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

试试这个。你需要管理员权限才能在 hosts 文件中添加一些东西

关于batch-file - Windows Batch 将记录添加到主机文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16773383/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com