168

I can't 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
Jij
  • 105
  • 1
  • 2
  • 12
Michael Skelton
  • 2,005
  • 3
  • 15
  • 7
  • 4
    There is some confusion in this question, because you say that you want to delete files, but the above line does not prompt for confirmation if C:\Test is a file. It prompts only if C:\Test is a *directory*. – Raymond Chen Aug 23 '11 at 13:55

5 Answers5

263

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

Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084
77

Add /Q for quiet mode and it should remove the prompt.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Nicholas Smith
  • 11,642
  • 6
  • 37
  • 55
5

I just want to add that this nearly identical post provides 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.

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.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
u8it
  • 3,956
  • 1
  • 20
  • 33
  • 4
    Disadvantage: this will not work in for example German Windows editions because they expect `J` to confirm – Marged Sep 12 '18 at 20:14
3

If you are using powershell, for example from vscode terminal, you can use -Recurse -Force instead:

del C:\Test -Recurse -Force

Note: I know that the question have cmd tag, but someone might come here for powershell or vscode.

Muhammad Yasirroni
  • 1,512
  • 12
  • 22
-1

You have the following options on Windows command line:

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

Try like:

net use H: /delete /y
Pang
  • 9,564
  • 146
  • 81
  • 122
slon
  • 1,002
  • 1
  • 8
  • 12