windows 删除批处理文件中的文件时如何跳过“你确定是/否”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7160342/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:42:30  来源:igfitidea点击:

How to skip "are you sure Y/N" when deleting files in batch files

windowsbatch-filecmd

提问by Michael Skelton

I cant for the life of me remember how to bypass the annoying prompt "are you sure Y/N" when deleting files.

我一辈子都记不起删除文件时如何绕过烦人的提示“你确定是/否”。

I seem to recall it was something like:

我似乎记得它是这样的:

del C:\Test && ECHO Y

回答by Kerrek SB

Use del /F /Qto force deletion of read-only files (/F) and directories and not ask to confirm (/Q) when deleting via wildcard.

使用del /F /Q武力删除只读文件(/F)和目录,而不是要求确认(/Q)通过通配符时删除。

回答by Nicholas Smith

Add /Qfor quiet mode and it should remove the prompt.

添加/Q安静模式,它应该删除提示。

回答by u8it

I just want to add that this nearly identical postprovides the very useful alternative of using an echo pipe if no force or quiet switch is available. For instance, I think it's the only way to bypass the Y/N prompt in this example.

我只想补充一点,如果没有强制或静音开关可用,这篇几乎相同的帖子提供了使用回声管的非常有用的替代方法。例如,我认为这是绕过此示例中 Y/N 提示的唯一方法。

Echo y|NETDOM COMPUTERNAME WorkComp /Add:Work-Comp

In a general sense you should first look at your command switches for /f, /q, or some variant thereof (for example, Netdom RenameComputer uses /Force, not /f). If there is no switch available, then use an echo pipe.

一般而言,您应该首先查看 /f、/q 或其某些变体的命令开关(例如,Netdom RenameComputer 使用 /Force,而不是 /f)。如果没有可用的开关,则使用回声管道。

回答by slon

You have the following options on Windows command line:

Windows 命令行上有以下选项:

net use [DeviceName [/home[{Password | *}] [/delete:{yes | no}]]

Try like:

尝试像:

net use H: /delete /y