title: Deleting temp files in batch file
body: <p>Just building a batch file to delete temp files on my vista machines @ home that I want to add to task scheduler. I have this so far, but I get  a lot of access denied, and it never finds a thumbs.db file or index.dat and there are heaps of them. What am I doing wrong?</p>
  
  <pre><code> attrib +a -s -h -r "%windir%\Temp\*.*" /s
    del /f /s /q "%windir%\Temp\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "thumbs.db" /s
    del /s /f /q "thumbs.db" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r *.tmp.log /s
    del /s /f /q "*.tmp.log" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r “%userprofile%\Application Data\Microsoft\Office\Recent\*.*” /s
    del /f /q /s “%userprofile%\Application Data\Microsoft\Office\Recent\*.*” &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.gid" /s
    del /s /f / q "%systemdrive%\*.gid" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.fts" /s
    del /s /f /q "%systemdrive%\*.fts" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.cnt" /s
    del /s /f /q "%systemdrive%\*.cnt" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.old" /s
    del /s /f /q "%systemdrive%\*.old" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.diz" /s
    del /s /f /q "%systemdrive%\*.diz" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.bak" /s
    del /s /f /q "%systemdrive%\*.bak" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.tmp" /s
    del /s /f /q "%systemdrive%\*.tmp" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.chk" /s
    del /s /f /q "%systemdrive%\*.chk" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.dmp" /s
    del /s /f /q "%systemdrive%\*.dmp" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.00?" /s
    del /s /f /q "%systemdrive%\*.00?" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\index.dat" /s
    del /s /f /q "%systemdrive%\index.dat" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\fw*log.txt" /s
    del /s /f /q "%systemdrive%\fw*log.txt" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\zalog*.txt" /s
    del /s /f /q "%systemdrive%\zalog*.txt" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\backup*.rdb" /s
    del /s /f /q "%systemdrive%\backup*.rdb" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*._mp" /s  
    del /f /s /q %systemdrive%\*._mp &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\*.log" /s 
    del /f /s /q "%systemdrive%\*.log" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\Temp\*.*" /s
    del /f /s /q "%systemdrive%\Temp\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\Users\Default\AppData\Local\Microsoft\Windows\History\*.*" /s
    del /f /s /q "%systemdrive%\Users\Default\AppData\Local\Microsoft\Windows\History\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\Users\Default\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" /s
    del /f /s /q "%systemdrive%\Users\Default\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\Users\Default\AppData\Local\Temp\*.*" /s
    del /f /s /q "%systemdrive%\Users\Default\AppData\Local\Temp\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\Users\Default\AppData\Roaming\Microsoft\Windows\Cookies\*.*" /s
    del /f /s /q "%systemdrive%\Users\Default\AppData\Roaming\Microsoft\Windows\Cookies\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\Users\Default\AppData\Roaming\Microsoft\Windows\Recent\*.*" /s
    del /f /s /q "%systemdrive%\Users\Default\AppData\Roaming\Microsoft\Windows\Recent\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%systemdrive%\Windows\Downloaded Program Files\*.*" /s
    del /f /s /q "%systemdrive%\Windows\Downloaded Program Files\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%ProgramData%\Apple\Installer Cache\*.*" /s 
    del /f /s /q "%ProgramData%\Apple\Installer Cache\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%ProgramData%\Apple Computer\Installer Cache\*.*" /s
    del /f /s /q "%ProgramData%\Apple Computer\Installer Cache\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%ProgramData%\Microsoft\Search\Data\Temp\*.*" /s
    del /f /s /q "%ProgramData%\Microsoft\Search\Data\Temp\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%ProgramData%\Temp\*.*" /s
    del /f /s /q "%ProgramData%\Temp\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Adobe\Flash Player\AssetCache\*.*" /s
    del /f /s /q "%appdata%\Adobe\Flash Player\AssetCache\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Macromedia\Flash Player\#SharedObjects\*.*" /s
    del /f /s /q "%appdata%\Macromedia\Flash Player\#SharedObjects\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\*.*" /s
    del /f /s /q "%appdata%\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\*.*" /s
    del /f /s /q "%appdata%\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Microsoft\Windows\Cookies\*.*" /s
    del /f /s /q "%appdata%\Microsoft\Windows\Cookies\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Microsoft\Windows\Recent\*.*" /s
    del /f /s /q "%appdata%\Microsoft\Windows\Recent\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Mozilla\Firefox\Crash Reports\*.*" /s
    del /f /s /q "%appdata%\Mozilla\Firefox\Crash Reports\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Sun\Java\Deployment\cache*.*" /s
    del /f /s /q "%appdata%\Sun\Java\Deployment\cache*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\uTorrent\*.*" /s
    del /f /s /q "%appdata%\uTorrent\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%userprofile%\AppData\Local\Temp" /s
    del /f /s /q "%userprofile%\AppData\Local\Temp" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%userprofile%\AppData\LocalLow\Temp" /s
    del /f /s /q "%userprofile%\AppData\LocalLow\Temp" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%userprofile%\AppData\Local\Microsoft\Windows Photo Gallery\Original Images\*.*" /s 
    del /f /s /q "%userprofile%\AppData\Local\Microsoft\Windows Photo Gallery\original Images\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%userprofile%\AppData\Local\Microsoft\Windows\Burn\*.*" /s 
    del /f /s /q "%userprofile%\AppData\Local\Microsoft\Windows\Burn\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.*" /s 
    del /f /s /q "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%userprofile%\AppData\Local\Microsoft\Windows\History\*.*" /s 
    del /f /s /q "%userprofile%\AppData\Local\Microsoft\Windows\History\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" /s 
    del /f /s /q "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%userprofile%\AppData\Local\Mozilla\Firefox\Profiles\*\Cache\*.*" /s
    del /f /s /q "%userprofile%\AppData\Local\Mozilla\Firefox\Profiles\*\Cache\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.db" /s
    del /f /s /q "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*.db" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Microsoft\Windows\cookies\*.*" /s
    del /f /s /q "%appdata%\Microsoft\Windows\cookies\*.*"  &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%appdata%\Microsoft\Windows\Recent\*.*" /s
    del /f /s /q "%appdata%\Microsoft\Windows\Recent\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%windir%\prefetch\*.*" /s
    del /f /s /q "%windir%\prefetch\*.*" &gt;&gt;"logs\temp.txt"
  
   attrib +a -s -h -r "%windir%\SoftwareDistribution\Download\*.*" /s
    del /f /s /q "%windir%\SoftwareDistribution\Download\*.*" &gt;&gt;"logs\temp.txt"
  </code></pre>