PDA

View Full Version : Clean a PC with autoexec.bat


Charter
12-05-2003, 04:29 PM
Title: How to clean up your PC hard drive by editing the autoexec.bat file.

Fact: The majority of people use a PC. Fact: The majority of people use Internet Explorer. Fact: Even if you delete cookies, information about your web surfing habits may be contained in index.dat files on your computer. The below instructions will remove such information from index.dat files, as well as remove other miscellaneous garbage including cookies, while leaving all programs fully functional.

Why pay for a cleanup program when you can do it yourself and know what's being implemented?

Note: These instructions were tested and successfully implemented on a Win98 operating system with C: as the hard drive label. You should read these instructions in full before attempting any changes. You may need to edit accordingly to fit your operating system and hard drive label. These instructions are on an "AS IS" basis. Use at your own risk. No support is offered. Read the below disclaimer.

Make sure you know what you are doing and don't make any typos!!!

Determine and write down the amount of used space on your hard drive. To do this, click Start, Programs, Windows Explorer. Click Files, Properties, and write down the amount of used space on your hard drive.

Locate and write down the full directory path to any cookies, history, temporary, and index.dat files or folders. To find such files or folders, click Start, Find, Files or Folders, search for the appropriate items on your hard drive, mouse over any entries under the In Folder column, and write down the full path.

Make sure you have at least one current startup disk!!! To make a startup disk, click Start, Settings, Control Panel. Double click Add/Remove Programs, click the Startup Disk tab, and follow the instructions. Why not make another startup disk to have as a backup startup disk? Just get another floppy disk and repeat this step.

Make sure to create at least one backup copy of your current autoexec.bat file!!! To make a backup copy, click Start, Programs, MS-DOS Prompt. An MS-DOS window opens and the directory that appears is likely C:\WINDOWS so type cd.. and hit return to get to the C:\ directory. At the C:\> prompt type copy autoexec.bat autoexec.backupcopy on the same line and hit return. Why not make two backup copies? To do so, type copy autoexec.bat autoexec.anotherbackupcopy on the same line at the C:\> prompt and hit return.

From the C:\> prompt in the MS-DOS window, type edit autoexec.bat on the same line and hit return to edit the autoexec.bat file. Add the below lines of code to the end of the file, making sure not to change anything else in the file, but FIRST NOTE that your directory paths may not be the same as the ones listed below, so make changes accordingly. Also, when adding the below lines to your autoexec.bat file, you will need to truncate file or directory names from step three that are over 8 characters long (e.g.: biglongname to biglon~1 and biglongnameagain to biglon~2). Further, any * that you see in the below lines is a place holder (e.g.: *.* means all name.type files and foo*.tmp means all files that start with foo and end with .tmp). One final note: Upon computer startup, the below code will delete the listed files, and Win98 will recreate desktop.ini and clean index.dat files, but other files will be permanently deleted. You can use all or some of the below lines of code, edit as you see fit, but you should keep the first line regardless, as this line speeds up the execution.


if exist c:\windows\smartdrv.exe c:\windows\smartdrv.exe 2048 16
DELTREE /y c:\windows\history\*.* > NUL
DELTREE /y c:\windows\tempor~1\Content.IE5\*.* > NUL
DELTREE /y c:\windows\temp\cookies\*.* > NUL
DELTREE /y c:\windows\temp\tempor~1\Content.IE5\*.* > NUL
DELTREE /y c:\windows\temp\history\History.IE5\*.* > NUL
DELTREE /y c:\windows\cookies\*.* > NUL
DELTREE /y c:\windows\applic~1\micros~1\office\recent\*.* > NUL
DELTREE /y c:\windows\applic~1\micros~1\intern~1\UserData\*.* > NUL
if exist c:\windows\ff*.tmp del c:\windows\ff*.tmp
if exist c:\windows\temp\*.tmp del c:\windows\temp\*.tmp


Make sure you didn't make any typos!!! Click File, Save, File, Exit in the MS-DOS Edit window and you will be returned to the C:\> prompt in the MS-DOS window. Type exit and hit return to close the MS-DOS window.

Restart your computer, and note that startup time may be slightly longer than before due to the execution of the new autoexec.bat file. Also, upon each subsequent startup, your computer will clean out the index.dat files as well as remove any new garbage.

After restarting your computer, repeat step two and compare these numbers with the original numbers to see the disk space reclaimed. How much disk space did you reclaim? I reclaimed around 2MB the first go... really amazing, on top of the fact that the new autoexec.bat stops those "Username, click here..." ads from using your username!

If you encounter serious computer problems or just don't like the effects of the new autoexec.bat file, then simply undo the above as shown below, using your startup disk to boot your computer if necessary. To use your startup disk to boot your computer, just stick the disk in the floppy drive and restart your computer. To undo the above, click Start, Programs, MS-DOS Prompt. Type cd.. to get to the C:\> prompt, type copy autoexec.backupcopy autoexec.bat on the same line, hit return, type y and hit return if prompted, type exit, hit return, remove your startup disk if it is the floppy drive, and restart your computer to go back to the original settings.

Below is an example of my autoexec.bat file before and then after the above additional code was added. Your autoexec.bat file will likely look different, not necessarily wrong... just different.

Before

@ECHO OFF
PATH=c:\windows;c:\windows\command;c:\ibmtools;c:\;%MAINDIR%\bin32
LH DOSKEY
c:\essolo.com
set PATH=C:\texmf\miktex\bin;%PATH%

After

@ECHO OFF
PATH=c:\windows;c:\windows\command;c:\ibmtools;c:\;%MAINDIR%\bin32
LH DOSKEY
c:\essolo.com
set PATH=C:\texmf\miktex\bin;%PATH%
if exist c:\windows\smartdrv.exe c:\windows\smartdrv.exe 2048 16
DELTREE /y c:\windows\history\*.* > NUL
DELTREE /y c:\windows\tempor~1\Content.IE5\*.* > NUL
DELTREE /y c:\windows\temp\cookies\*.* > NUL
DELTREE /y c:\windows\temp\tempor~1\Content.IE5\*.* > NUL
DELTREE /y c:\windows\temp\history\History.IE5\*.* > NUL
DELTREE /y c:\windows\cookies\*.* > NUL
DELTREE /y c:\windows\applic~1\micros~1\office\recent\*.* > NUL
DELTREE /y c:\windows\applic~1\micros~1\intern~1\UserData\*.* > NUL
if exist c:\windows\ff*.tmp del c:\windows\ff*.tmp
if exist c:\windows\temp\*.tmp del c:\windows\temp\*.tmp

Enjoy!!!

Disclaimer: All information and code provided herein are without warranty of any kind, expressed or implied, including but not limited to the implied warranties of merchantability or fitness for any purpose. In no event shall ThinkDing or PhpDig be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits, or special damages, even if ThinkDing or PhpDig has been advised of the possibility of such damages.

radroach
02-27-2004, 11:06 AM
How would you pull that off using windows xp or win2k?

Charter
03-05-2004, 11:55 AM
Hi radroach, and welcome to PhpDig.net!

I haven't used WinXP or Win2K enough to write a decent tutorial for those OS but there are a couple of pages here (http://www.experts-exchange.com/Operating_Systems/WinXP/Q_20810903.html) and here (http://www.mvps.org/winhelp2002/delcache.htm) that you may find useful.

radroach
03-05-2004, 12:28 PM
Yep all I had to do was to change the permissions thanks that helped.