可在命令提示符下使用,但不能在BAT文件或CMD文件中使用 [英] Works in Command Prompt but not in BAT-file or CMD-file

查看:416
本文介绍了可在命令提示符下使用,但不能在BAT文件或CMD文件中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于WINDOWS DEFENDER的问题,我需要执行以下操作:

Due to problem with WINDOWS DEFENDER I need do the following:

for /r "%appdata%\..\Local\MyProg\2.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%\..\Local\MyProg\2.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆