中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟
中国DOS联盟论坛
现在时间是 2026-08-07 09:23
48,040 主题排行 / 350,125 发帖 / 今日 0 篇 / 48,252 会员排行
DOS批处理 & 脚本技术(批处理室) » FOR 是否受其它命令干扰
可打印版本  648 / 0
第1楼 hy433124shc 发表于 2008-01-26 23:44
中级用户 发帖 75 积分 201
FOR 是否受其它命令干扰
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 ]
[ 联系联盟系统管理团队 - 中国DOS联盟 - 标准版 ]
Sponsored by ifanr Inc | © 2001–2023