Delete on Startup

Question: Is it possible to download some free software that will delete the content of a folder on startup?

Answer: The software to do this isn't free but you have already bought it - it is called Windows.

All you need to do is to create a file called empty.bat containing the following commands:

if x%1x == xx goto error
deltree %1 /Y
md %1
goto end
echo You forgot to enter a directory

You now have the ability to empty the content of a specified folder using this batch file. For example, to empty out c:\temp you need to execute empty c:\temp and the temp folder will be deleted and recreated (thus removing all of its contents). As folders such as this one are just about always in use by Windows you need to execute the command before windows starts using it. You do this by placing the command inside of autoexec.bat which executes before the graphical interface loads.

If you have multiple folders you want to empty out then just specify as many empty commands inside of autoexec.bat as you need.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow