Auto Delete Files And Folders During Windows 9x Bootup     View/Save PDF     (35.5KB)

For: Windows 95 / Windows 98

Published: ? | Last Updated: 16Mar02 | Status: Discontinued

I. Introduction
II. Important Notes Before Starting
III. Editing Autoexe.bat


I. Introduction

Autoexec.bat is a Windows 95 and Windows 98 (Windows 9x) file located in one's Boot Drive root directory, usually C:\. In the old days one made entries into autoexec.bat so old 16-bit Windows applications would run in the Windows 9x 32-bit environment.

For our purposes, though, all one needs to know about autoexec.bat is that Windows 9x starts by booting to DOS, that autoexec.bat (automatically executed batch file) is read during the boot process, and that any commands located within autoexec.bat will be executed.

DELTREE is a DOS command which can delete files and/or folders. To automatically delete files/folders during bootup, statements containing the deltree command will be added to autoexec.bat.

The path indicated in a deltree statement determines what will be deleted. More specifically, the following should be considered.

Note: Autoexec.bat is read while one's computer is in DOS-Mode. Therefore, any path specified in a deltree statement must be a DOS path. DOS allows only eight letter folder names, eight letter filename prefixes, and three letter file extensions. For example, the Window's folder c:\program files\ becomes c:\progra~1\ in DOS, and the Window's file longfilename.extension becomes longfi~1.ext in DOS.

There are a number of files and folders one might want to delete every time one's computer is booted. The following are covered in this post.

  1. Internet Explorer


  2. Netscape 4.x


The command line switch, /y, will be used in conjunction with the deltree command as follows:

deltree /y c:\afolder\filename.ext

The use of /y avoids DOS prompting one to confirm the deletion of the file(s)/folder(s) specified in the deltree statement. For more on deltree.


II. Important Notes Before Starting

Editing autoexec.bat can cause some problems. In the event that it does, the following is provided so one can easily restore autoexec.bat to its original state.

  1. Make two copies of the Windows StartUp Disk.
  2. Copy c:\autoexec.bat to two separate floppy disks.

    Important Note: The version of autoexec.bat found at C:\ is quite different than the version found on the Windows StartUp Disk. So, yes, if one wants their Windows StartUp Disk to function, one must copy C:\autoexec.bat to a different floppy.

  3. If something goes wrong, reboot computer using the Windows StartUp Disk.
  4. At the A: prompt replace the Windows StartUp Disk with the floppy containing the copy of c:\autoexec.bat.
  5. Type copy a:\autoexec.bat c:\autoexec.bat and hit [Enter].
  6. Overwrite? Type y and hit [Enter].
  7. Remove the floppy from the A: drive and reboot computer via [ctrl-alt-del].

III. Editing Autoexe.bat

  1. Taking all the above into consideration, click Start | Programs | Accessories | Notepad.
  2. Click File | Open.
  3. Point the Look in field to c:\
  4. In the Files of Type drop-down select All Files (*.*).
  5. Double click autoexec.bat
  6. Take a look at the contents of autoexec.bat. A good place to insert the deltree statements is at the end of the file. For example, an autoexec.bat file may look like this.

    @TYPE INSTOS.MSG
    SET PATH=D:\Perl\bin;%PATH%

  7. Insert a new line for each deltree statement one wishes to add.
  8. Type in the deltree statement(s).

    Note: Of course one is free to add to, and to subtract from, the deltree statements mentioned. Just make sure the path is DOS, and that the path is deleting the file/folder one wants.

  9. Remove any blank lines one might have introduced and make sure there are no extra spaces preceding or following any line. For example, a finished autoexec.bat file may look like this.

    @TYPE INSTOS.MSG
    SET PATH=D:\Perl\bin;%PATH%
    deltree /y c:\recycled\*.*
    deltree /y c:\windows\cookies\*.*
    deltree /y c:\windows\history\*.*
    deltree /y c:\windows\recent\*.*
    deltree /y c:\windows\tempor~1\content.ie5\*.*
    deltree /y c:\progra~1\netscape\users\mailServerUserName\cache\*.*
    deltree /y c:\progra~1\netscape\users\mailServerUserName\cookies.txt
    deltree /y c:\progra~1\netscape\users\mailServerUserName\netscape.hst

  10. Click File | Save.
  11. Close all open Windows and reboot computer.
  12. To test if one's deltree statements are working, determine if the files/folders exist prior to rebooting. Reboot computer. And see if the files/folders previously witnessed still exist.

A special thanks to grilled cheese for suggestions/corrections.