We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

DOS BATCH USING DEL needs to auto "yes"

kinkajou
kinkajou asked
on
Medium Priority
4,064 Views
Last Modified: 2013-12-29
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 :)
Comment
Watch Question

Commented:
Add the /Q to the statement to stop being prompted Y/N



Craig

Author

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).

Commented:
the /Q switch needs to be at the end of the statement
For Example

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

Give this a try

Author

Commented:
What I typed and the results:

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

Commented:
Sorry, my fault

Forgot that I was on my NT box....Duh......

Author

Commented:
Ah, the prowess of NT...

Commented:
If deleting everything, use DELTREE/Y.
The "Y" switch confirms all file deletions without prompting.
I hope it helps.
Ralph

Author

Commented:
Thanks Ralph, but it is not convienent to remove the directory that contains the files.

Commented:
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


Author

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.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Ah ha, very nice. And to think that I gave in too soon...
Thanks Mark and your profile is so informative.
:)

Commented:
The only thing missing is to add  >nul  to keep it quiet.
Ralph

Author

Commented:
Thank you very much Ralph.

Commented:
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

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.