Deleting files in MS-DOS without a prompt

Updated: 04/26/2017 by Computer Hope

Delete file imageBy default, MS-DOS and the Microsoft Windows command line will not prompt a user or give a user a prompt or warning when deleting files on a computer using the del command. However, when attempting to delete a directory using the del, deltree, or rmdir command, ensure that it isn't empty or you will receive a warning or error.

Note: When deleting anything from MS-DOS or the Windows command line it is not sent to the Recycle Bin.

Deltree command

To suppress the prompting use the deltree command and add the tag /y, as shown in the example below that deletes all files in the Windows temp directory.

deltree c:\windows\temp\*.* /y

Note: The above command does not work in all versions of Windows and MS-DOS.

If this command does not work we would recommend that you create a batch file with the below command in the batch file.

echo y | del %1\*.*

Once created, you can type the name of the batch file then the name of the directory that you want to delete.

Rd and rmdir command

Users who want to delete a directory containing files in a Windows command line window running under Microsoft Windows 2000 or later can also use the rmdir or rd command with the /S option.

Erase command

If you're running a later version of Microsoft Windows and using the Windows command line you can also use the erase command to delete files without a prompt.

Additional information

  • See our delete definition for further information on this term and related links.
  • See our del command pages for further information on each.