繁体   English   中英

命令在命令提示符中有效,但在批处理文件中无效

[英]Command works in Command Prompt but not in a batch file

试图打印出文件的 8dot3 名称,当我在命令提示符中粘贴该行时它确实有效,但当我从批处理文件中运行它时则无效。

粘贴时的结果:

D:\tmp>cmd /e:on /c for %A in (8088_othello.com) do @echo %~nxsA

8088_O~1.COM

批处理文件的结果:

D:\tmp>lfn.bat

D:\tmp>cmd /e:on /c for ~nxsA

~nxsA was unexpected at this time.

还需要什么才能使其在批处理文件中工作?

你需要转义 % 是批处理文件

只需在 (8088_othello.com) 中为 %%A 键入 cmd /e:on /c 做 @echo %%~nxsA

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM