Please Read: Significant Update Planned, Migrating Forum Software This Month

See more
See less

Disk Cleanup File (Cleanup.bat) HELP

  • Filter
  • Time
  • Show
Clear All
new posts

  • Disk Cleanup File (Cleanup.bat) HELP

    I created a "Cleanup.bat" and placed in my start menu list.
    This is the file. (NOTE: I didn't script this myself, I followed a tutorial on a tweak site and it provided this code to use.)

    c:\windows\system32\cleanmgr.exe /dc /sagerun: 1
    cd \
    cd c:\windows\prefetch
    del *.* /q

    I have two questions. First, when I run "Cleanup" it does start, and it goes through the deleting process on my C drive, but then after it finishes deleting the C drive files it starts to do the process for my G drive (external drive), and I don't want that. Is there a way to make it just only delete for the C drive?
    My second question is how to add in more files or folders in the process to be deleted. I want to add my "Temp" folder, so would it be this?

    c:\windows\system32\cleanmgr.exe /dc /sagerun: 1
    cd \
    cd c:\windows\prefetch
    cd c:\windows\temp
    cd c:\mymiscfile.txt
    del *.* /q

    Just keep adding in a new file or folder location like so to add a new delete process? If not, could someone please explain how so. Also, how would you add a single file to delete, can someone post an example for the above cleanup file.

    If it is too much to read I guess this is it simplified.

    How do I stop that script from doing my G (external) drive after it completes the process on my C drive?
    How do you add a single file somewhere on your comp to delete to the script?
    How do you add a folder to empty out to the script?
    How do you add a folder to actually delete it to the script?

    Thank you.

  • #2
    /d driveletter: - This option specifies the drive that you want Disk Cleanup to clean.

    Note: The /d option is not utilized with /sagerun: n.;EN-US;Q315246
    Guy Teverovsky
    "Smith & Wesson - the original point and click interface"


    • #3
      As Guy says for the Drive Letter Issue, take off sagerun or it will run on G:

      For the deletion, you need to delete once you have gone to the folder not after you have changed to another.

      The easiest way is to run

      c:\windows\system32\cleanmgr.exe /dc
      del c:\windows\prefetch\*.* /q
      del c:\windows\temp\*.* /q
      del c:\mymiscfile.txt

      * Shamelessly mentioning "Don't forget to add reputation!"