• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3262
  • Last Modified:

DOS BATCH USING DEL needs to auto "yes"

I have a line in a DOS BATCH file "If Exist *.* del *.*". I need to automate this delete command so that it will not ask if I want to delete all files in the directory and will not show/echo anything to the screen so that the user is unaware of the delete. NOTE: this is not for a virus but for a build.bat as part of a project :)
0
kinkajou
Asked:
kinkajou
  • 7
  • 4
  • 3
  • +1
1 Solution
 
cmcgeeCommented:
Add the /Q to the statement to stop being prompted Y/N



Craig
0
 
kinkajouAuthor Commented:
Thanks Craig, but...

"del /q *.*" or "del /Q *.*" or "erase /Q *.*" or "erase /q *.*" yields: Invalid switch. I am using Windows SR2.1 and Windows 98 ver 4.00.1111 (should be the release version of 98).
0
 
cmcgeeCommented:
the /Q switch needs to be at the end of the statement
For Example

Del *.* /q
del autoexec.bat /q

Give this a try

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
kinkajouAuthor Commented:
What I typed and the results:

C:\temp>del *.* /q
Invalid switch - /Q

0
 
cmcgeeCommented:
Sorry, my fault

Forgot that I was on my NT box....Duh......
0
 
kinkajouAuthor Commented:
Ah, the prowess of NT...
0
 
rmarottaCommented:
If deleting everything, use DELTREE/Y.
The "Y" switch confirms all file deletions without prompting.
I hope it helps.
Ralph

0
 
kinkajouAuthor Commented:
Thanks Ralph, but it is not convienent to remove the directory that contains the files.
0
 
rmarottaCommented:
I think you'll find that the only switch option for the DEL or ERASE command is "/P". (Which prompts user for confirmation before execution)
A directory that's been erased with DELTREE can be quietly re-created simply enough.
Ralph


0
 
kinkajouAuthor Commented:
Ralph,

Yes, I agree. I was hoping there might be somthing undocumented? How disappointing that these DOS tools are so limiting. Why don't you post an answer to get the points.
0
 
Mark AertsCommented:
first, make a file called yes.txt with just a y (the letter "y")
then: DEL . < YES.TXT
and......
all gone

Mark
0
 
kinkajouAuthor Commented:
Ah ha, very nice. And to think that I gave in too soon...
Thanks Mark and your profile is so informative.
:)
0
 
rmarottaCommented:
The only thing missing is to add  >nul  to keep it quiet.
Ralph

0
 
kinkajouAuthor Commented:
Thank you very much Ralph.
0
 
rmarottaCommented:
I'm sure there are other, more elegant ways to accomplish what you want.
If this gets you going though, then the KISS principle applies.  :)
Regards to all,
Ralph

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 7
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now