1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

How do empty recycle bin from command line

Discussion in 'Windows XP' started by ajpow365, Oct 17, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. ajpow365

    ajpow365 Thread Starter

    Joined:
    Oct 5, 2007
    Messages:
    2
    I am creating a .bat file to do a task and after it is complete, I delete some files.

    How do I clear the recycle bin?

    Can't seem to get a good answer.

    Thx.:eek:
     
  2. WhitPhil

    WhitPhil Gone but never forgotten Trusted Advisor

    Joined:
    Oct 4, 2000
    Messages:
    8,684
    The files shouldn't be in the recycle bin. They will be "permanently" deleted.
     
  3. VegasRage

    VegasRage

    Joined:
    Jun 26, 2008
    Messages:
    1
    Assuming you want to script clearing the recycle bin as part of an automated cleanup, then easiest way to do it thoroughly is to use the CleanMgr utility from the command line.
    Create a text file titled “DiskCleanmgr.reg” in the same directory as your batch file and copy and paste the below 4 lines into it.


    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin]
    "StateFlags0001"=dword:00000002


    Then in your batch file add the below two lines


    regedit /s DiskCleanmgr.reg
    cleanmgr /sagerun:1


    The reason I have made the option /sagerun:1 is because the StateFlags0001 in the regedit file is set to 1. If you didn’t do the registry hack then you would have to manually pick the recycle bin after running the command cleanmgr /sageset:1, the registry file keeps setting the options silent. When run the utility graphically launches but runs and closes automatically.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/639485