适用于命令提示符但不适用于 BAT 文件或 CMD 文件 [英] Works in Command Prompt but not in BAT-file or CMD-file
本文介绍了适用于命令提示符但不适用于 BAT 文件或 CMD 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于 WINDOWS DEFENDER 的问题,我需要执行以下操作:
Due to problem with WINDOWS DEFENDER I need do the following:
for /r "%appdata%..LocalMyProg2.0" %D IN ("*MyProgram.exe") DO "%~fD
它在 COMMAND PROMPT 中完美运行,但在批处理文件或 cmd 文件中无法正常运行 - 为什么?
It works perfect in COMMAND PROMPT but not in batch-file or cmd-file - why?
如何将可执行文件制作为批处理文件或.cmd"?
How do I make in a excutable file as a Batch-file or ".cmd"?
推荐答案
在批处理文件中运行 for
循环时,需要在预定义变量中使用额外的 %
.所以应该是:
When running for
loops in a batch file, you need to use an additional %
in predefined variables. So it should be:
for /r "%appdata%..LocalMyProg2.0" %%D IN ("*MyProgram.exe") DO "%%~fD
我建议您通过从 cmdline 运行 for/?
来阅读文档齐全的帮助.保证您会从中受益!
I suggest you read up using the well documented help by running for /?
from cmdline. You will benefit from it, guaranteed!
这篇关于适用于命令提示符但不适用于 BAT 文件或 CMD 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文