批处理相关

来源:百度知道 编辑:UC知道 时间:2024/05/31 13:57:48
我自己做了个批处理,但是没达到我的要求
@echo off
if exist 1.txt del 1.txt
tracert www.hao123.com -h 2 >1.txt
if exist 2.txt del 2.txt
find " 2" 1.txt >2.txt
if exist IP.txt del IP.txt
:::::::下边这句是把IP提取出来,但是不知道怎么让它生成TXT文件
for /f "skip=2 tokens=15" %%I in (2.txt) do set IP=%%I
:::::::这句是显示当前IP.TXT中的内容
FOR %%1 IN (IP.TXT) DO TYPE %%1
3楼的朋友,我应该直接告诉你我做这个批处理的用意是:通过批处理来显示外网IP

如果你连我这里写的都看不懂的话,那我也没办法了。

因为你在for循环里用了set所以你的值根本没设置进去。
如果要用for里用set命令的话,那就要在for之前加上
setlocal ENABLEDELAYEDEXPANSION
然后在set,并且在for循环里调用变量时要用!而不是%
你这里就是

setlocal ENABLEDELAYEDEXPANSION
for /f "skip=2 tokens=15" %%I in (
'more 2.txt'
) do (
set IP=%%I
echo !IP!>>ip.txt
)

@echo off
if exist 1.txt del 1.txt
tracert www.hao123.com -h 2 >1.txt
if exist 2.txt del 2.txt
find " 2" 1.txt >2.txt
if exist IP.txt del IP.txt
:::::::下边这句是把IP提....
for /f "skip=2 tokens=15" %%I in (2.txt) do set IP=%%I

echo %ip%>ip.txt

:::::::这句是显示当前IP.TXT中的内容
FOR %%1 IN (IP.TXT) DO TYPE %%1

为什么要生成那么多临时文件??

以下是代码(原理我没仔细看,只是针对代码)。

@echo off
for /f "skip=1 tokens=15" %%i in ('tracert cmd 相关 &dat批处理 批处理??? 批处理、? 请教批处理相关,如何把结果显示出来 什么批处理? photoshop 批处理 批处理是什么? 什么是批处理?? 批处理教程 关于批处理~!