Batch Automation

Discussion in 'General Software' started by Jeremy, Feb 22, 2006.

  1. Jeremy

    Jeremy Black Sheep

    Recently, a few forummers here was kind enough to pass me their batch files and among the batch files was one that's used to clear the temp folder. However in Windows XP there's another temp folder located in your profile settings and when I added the following lines to the batch files, nothing seems to happen to it, so what gives?

    del c:\windows\temp\*.* /Q
    del C:\Documents and Settings\Jeremy Tan\Local Settings\Temp\*.* /Q
     
  2. peaz

    peaz ARP Webmaster Staff Member

    The easiest way to know where to clear the files is to use the environment variables since that's also where Windows get the temp folders location.
    There's two folders and their environment variable name is TMP and TEMP
    (Note: myself, i always redefine the TMP and TEMP folders to C:\TEMP\ for easy management ;) )

    so you can actually use this

    del %TMP%\*.* /Q
    del %TEMP%\*.* /Q

    There's is one problem with deleting files this way. There's usually some files there that's still being used by windows. Thus, they are locked and there's nothing you can do to remove them. the only way is to run this script during boot time or right before windows shut down.

    one more things. The default del command is quite primitive as it cannot delete sub directories.
    My suggestions is to do a search online and get a more powerful del command that also allows you to delete sub directories. :) There are such utilities as I've used them before.

    Edit: Add attachment for delete.exe utility
     

    Attached Files:

  3. Dashken

    Dashken Administrator!

    Here's a forcedelete utility that I tried just now. Well, didn't actually try on system file :p. But I tried to delete an opened zip file. It worked on the locked file. It closed the handle and deleted the file. Nice.. :D

    Got it from... http://www.codeguru.com/Cpp/W-P/files/fileio/article.php/c1287/

    The *.exe is in this folder.. NtSystemInfo\ForceDel\Release\
     

    Attached Files:

  4. peaz

    peaz ARP Webmaster Staff Member

    actually, you are NOT suppose to force delete those files that are being used in the TMP and TEMP folders... running programs will fail! or shut down! LOL
     
  5. 1031982

    1031982 Just Started

    Yep peaz! That's why I never put those directories in the batch files. Programs use them as a backup, or long term temp files. I just compress them, because one time I deleted them and when I rebooted, a few things didn't open. Then when I tried to do a repair install, it said the setup files could not be found. Luckily, I left them in the recycling bin, so I just un-installed them. After that, everything was fine!
     
  6. Dashken

    Dashken Administrator!

    LOL! I didn't say you should use for the TMP or TEMP folders. :D

    Actually I never clear TEMP/TMP files coz sometimes there are installation files in there. Dang... actually I never clean my Internet temp or temp files, unless something goes wrong. :mrgreen:

    That forcedelete was for you to forcedelete some files or folders that you can't delete coz some apps are using and you don't know which apps and you don't want to restart windows to release it. Last but not least, you have to know what files you are actually deleting to make sure after you delete it, your windows still runs normally. :roll:
     
  7. peaz

    peaz ARP Webmaster Staff Member

    Haha. posting that here might have confused some people mah. But it's a good find. THe only other utility i know of marks files for deletion when the pc restarts. Not forcing the apps to shut down to delete the file.
     
  8. hyper_raider

    hyper_raider shutdown -h now

    Well if you must delete can you delete the files when windows is shutting down?
     

Share This Page