scripting on batch
batch脚本,在我看来就是cmd.exe
命令。这种脚本存在.bat
或.cmd
中,可以双击运行。今天我需要做一个来帮小白改hosts
。
目标:用户提供一个IP。抹除原hosts
,然后将大量的Google域名绑到那个IP上。
尝试:
@echo off set /p var=please provide a Google IP echo %var% tse 32.334.23.32 > %windir%\system32\drivers\etc\test.txt set /p test=some aet ad;[ pause
尝试成功。投入使用:
@echo off echo WARNING: your current hosts file WILL BE OVERWRITTEN. set /p ipval=please provide a Google IP, or close the window: echo #http://OpenGG.me/geek/generate-hosts-for-google/ > %windir%\system32\drivers\etc\hosts @echo on echo %ipval% v15.nonxt4.c.android.clients.google.com >> %windir%\system32\drivers\etc\hosts echo #a shit lot of other lines like the one above pause
行了,就是这样。哦对了,这当然需要以管理员权限运行才有用。
- command line - How to request Administrator access inside a batch file - Stack Overflow
- BAT脚本编写要点(1)_特殊字符 - 小兵的专栏 - 博客频道 - CSDN.NET
- windows batch prompt user input set p - Google Search
- batch file - In Windows cmd, how do I prompt for user input and use the result in another command? - Stack Overflow