中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-07 11:14
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » FOR 是否受其它命令干扰 查看 649 回复 0
楼 主 FOR 是否受其它命令干扰 发表于 2008-01-26 23:44 ·  中国 山东 潍坊 电信
中级用户
★★
积分 201
发帖 75
注册 2007-02-24 00:26
19年会员
UID 80034
性别 男
状态 离线
C:\Documents and Settings\game>WMIC LOGICALDISK WHERE Description="可移动磁盘" GET NAME >>3.txt

C:\Documents and Settings\game>type 3.txt
Name
F:

C:\Documents and Settings\game>for /f "tokens=1 delims= " %1 in (3.txt) do @echo %1

没结果
C:\Documents and Settings\game>echo Name>>4.txt

C:\Documents and Settings\game>echo F:>>4.txt

C:\Documents and Settings\game>type 4.txt
Name
F:

C:\Documents and Settings\game>for /f "tokens=1 delims= " %1 in (4.txt) do @echo %1
Name
F:
有结果
C:\Documents and Settings\game>for /f "skip=1 tokens=1 delims= " %1 in(4.txt) do @echo %1
F:
有结果

为什么有的有结果,而有的没有??/?
是不是与 WMIC 命令有关

而用下式
for /f "skip=1" %%a in ('WMIC LOGICALDISK WHERE Description^="可移动磁盘" GET NAME') do (start %%a\shc~1)
有结果

[ Last edited by hy433124shc on 2008-1-27 at 05:14 AM ]
论坛跳转: