How to Create a Disk Cleanup BAT File
By Nick Davis
As you visit websites and install programs on your computer, a copy of each website you visit and temporary setup files are stored on your computer's hard drive. These files consume a large amount of space and can slow down your computer's performance. To remove these unnecessary files, you don't have to buy a third-party application. The Windows operating system includes a utility, Disk Cleanup, for cleaning up your hard drive. You can even create a batch (BAT) file using a text editor to automate the cleanup process.
Creating the BAT File
Step 1
Open your computer's text editor, WordPad, Notepad or other text editor. The text editor will open to a blank text editor file.
Step 2
Enter “c:\windows\system32\cleanmgr.exe /dc /sageset: 1” on the first line of the blank text editor file. Press the “Enter” or “Return” key on your computer's keyboard.
Step 3
Enter “c:”. Press “Enter” or “Return.” Enter “cd \”. Press “Enter” or “Return.”
Step 4
Enter “cd c:\windows\prefetch”. Press “Enter” or “Return.” Enter “del . /q”. Press “Enter” or “Return.”
Step 5
Click “File,” “Save As.” Click on the down arrow on the box next to “Save in:.” Double click on “C:\,” “Windows,” “System32.”
Step 6
Click on the down arrow on the box next to the wording “Save as type.” Select “All Files.”
Step 7
Enter “clean.bat” in the “File name:” box. Click “Save.”
Step 8
Click “File,” “Exit.”
Setting the Attributes of the Clean.Bat File
Step 1
Click “Start,” “My Computer.”
Step 2
Double click on “C:\” drive icon. Double click the “Windows” folder. Double click the “System32” folder.
Step 3
Double click the “clean.bat” file to run the batch file. The “Disk Cleanup Settings” dialog box will open.
Step 4
Click on the items you want the Disk Cleanup utility to remove during the cleanup process. Click “OK” once you are finish selecting the items.
Step 5
Right-click on the “clean.bat” file in the “System32” folder. Click “Edit.” The batch file will open in the text editor you used to create it.
Step 6
Replace the first line of the batch file to “c:\windows\system32\cleanmgr.exe /dc /sagerun: 1”.
Step 7
Click “File,” “Save.” Click “File,” “Exit\" to close the text editor.
Automating the Clean.bat File
Step 1
Click “Start,” “Control Panel.” Double click the “Scheduled Tasks” icon.
Step 2
Click “File,” “New,” “Scheduled Task.”
Step 3
Enter “Cleanup” in the box highlighted “New Task.” Press “Enter” or “Return.”
Step 4
Right-click on “Cleanup.” Click “Properties.”
Step 5
Click on the “Browse” button next to the heading “Run.” Navigate to the “C:\”, “Windows,” “System32” directory. Click on the “clean.bat” file to select it. Click “Open.”
Step 6
Click on the “Schedule” tab. Select when you want the Disk Cleanup batch file to run under the “Schedule Task:,” “Start time:” and “Schedule Task Daily” headings. Click “Apply,” “OK.”
Tips
- If you don't want the Disk Cleanup batch file to run automatically, skip the steps in the “Automating the Clean.bat File” section.
- You can run the Disk Cleanup batch file by navigating to the “System32” directory and double clicking the “clean.bat” file.
Writer Bio
Nick Davis is a freelance writer specializing in technical, travel and entertainment articles. He holds a bachelor's degree in journalism from the University of Memphis and an associate degree in computer information systems from the State Technical Institute at Memphis. His work has appeared in "Elite Memphis" and "The Daily Helmsman" in Memphis, Tenn. He is currently living in Albuquerque, N.M.