View Full Version : Help with a batch file

10-07-2003, 03:44 PM
I've made a .bat file to run on startup;

@echo off
cd windows\temp
del *.* /y

As many of you will be able to see immedialtely, this presents a very frustrating problem. I get prompted with a Y/N if I want to delete or not.

Is there a way around this to make it do it without asking?


10-07-2003, 03:50 PM
I created a file with a Y in it. Then pointed it to the command.

e.g. del *.* <y.txt

Try that.

10-07-2003, 03:55 PM
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

names Specifies a list of one or more files or directories.
Wildcards may be used to delete multiple files. If a
directory is specified, all files within the directory
will be deleted.

/P Prompts for confirmation before deleting each file.
/F Force deleting of read-only files.
/S Delete specified files from all subdirectories.
/Q Quiet mode, do not ask if ok to delete on global wildcard
/A Selects files to delete based on attributes
attributes R Read-only files S System files
H Hidden files A Files ready for archiving
- Prefix meaning not

If Command Extensions are enabled DEL and ERASE change as follows:

The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.

As you can see above, using /Q should help.

10-07-2003, 03:58 PM
Try using "deltree /y *.*" instead. It has the side affect of also deleting any directorys there as well.

Otherwise a simpler version of kiwitt's idea would be:

echo y | del *.*

It saves the need of a seperate file.

10-07-2003, 04:02 PM
Is that the NT version of DEL gf?

The dos/win9x version only has /P.

10-07-2003, 04:05 PM
Yes, XP version (straight from del /?)

Graham L
10-07-2003, 05:35 PM
I'd go for deltree /y, with an extra line to replace the \tmp directory to save arguments with programmes which have to have it.
But sometimes after a crash you don't want the contents of \tmp deteted. It might hold essential stuff. Such automatic deletions always cause tears sooner or later. :D Some intentional deletions cause tears, too. :_|