| 1. |
Solve : Remove the content of Temp Directory!???? |
|
Answer» Hello folks, i want a bat file to remove every thing from the %temp% directory and my code is Code: [Select]del /q "%userprofile%\Local Settings\Temp\*.* but this bat file only removes the files and not the folders as ccleaner does. BC: I know you're going to say why I am wrong. Go ahead. Main problem would be rerouting the temp files to the RAM disk, since %TEMP% is a per-user variable. And of course the issue of using up your RAM for the otherwise menial task of storing temporary files. Aside from that, it's not a terrible idea on XP and earlier if the system has GOBS of RAM but low disk space. Quote Main problem would be rerouting the temp files to the RAM disk, since %TEMP% is a per-user variable. True. That's why I have created a batch that sets temp variables easily, so that it can be done for each user. Code: [Select]echo off SET /P DIRNAME=Type the path to the RAMDrive: REG ADD "HKCU\Environment" /v TEMP /t REG_EXPAND_SZ /d %DIRNAME% /f REG ADD "HKCU\Environment" /v TMP /t REG_EXPAND_SZ /d %DIRNAME% /f REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TEMP /t REG_EXPAND_SZ /d %DIRNAME% /f REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TMP /t REG_EXPAND_SZ /d %DIRNAME% /f Quote from: Raven19528 on November 15, 2011, 10:11:58 AM Try using this: aannnnn Raven19528 what do you know Code: [Select]rd /s /q "%userprofile%\Local Settings\Temp" your code works and it removes the folder as well as the files. Good going, by the way rd is the remove directory isn't it:then how come it removes the file as well . Sorry BC Programmer your code i.e., Code: [Select]del /q /s "%userprofile%\Local Settings\Temp\*.* doesn't work it only removes the files same like my code except giving the /s switch. Same was for the other codes. Anyways isn't it GREAT to know what a bat file can achieve to do the same task. PS: Just thanked Raven for this job.is the 4KB used for the folder's directory entry really that critical? Quote from: Floppyman on November 16, 2011, 02:30:57 AM by the way rd is the remove directory isn't it:then how come it removes the file as well . Using the /s switch on the rd (which yes, is remove directory, same as rmdir) causes it to remove the folder and all files and folders within the directory. You can view the full explanation by typing rd /? at the cmd prompt.Hello hello newsflash Code: [Select] rd /s /q "%userprofile%\Local Settings\Temp" this code of Raven has stopped working , last time i had to perform a System Recovery and what do you know the bat file doesn't work to well. It removes the TEMP folder entirely, has anyone even been trying this out. Its really important for me. BC programmers does perform a little better Code: [Select]del /q /s "%userprofile%\Local Settings\Temp\*.* Any suggestion i have to be better aware next time when i thank someone. Little HELP here. Quote from: Floppyman on November 25, 2011, 10:07:04 PM Any suggestion i have to be better aware next time when i thank someone. What I do is perform rd /s . (can you see the dot?) from within each directory I want to clear. Being logged in to a directory via the CD command means it won't get deleted. I tend to always add the /d switch to the cd command but I guess that's a personal preference. To turn off the "., Are you sure (Y/N)?" prompt, use the /q switch and if you don't want to see the messages about what it couldn't delete, add 2>nul to redirect stderr to the null device. For example: (the paths are mine, yours may differ) cd /d %temp% & rd /s . /q 2>nul cd /d %windir%\temp & rd /s . /q 2>nul And Floppyman, maybe a bit less of the smart mouth? People have given their time freely to help you, and have done their best. Crude ungrateful sarcasm spoils the forum and looks bad. Anyhow, that's just my opinion. Quote from: Floppyman on November 25, 2011, 10:07:04 PM Little help here. No need for this either. Helping you is not obligatory, and the goodwill that motivates people to do so is a fragile thing that is easily dispersed, as I hinted above. I use to have this on a CD Of course my 'CleanIt' folder also contained these files: AllDone.exe (this is a 'dropcount' file) CHOICE.com sizeOLD.exe (this is a 'dropcount' file) sizeNEW.exe (this is a 'dropcount' file) taskkill.exe TempClose.exe (An old AutoIt file) wscript.exe Anyway, if you want me to zip it up and attach all this stuff let me know Actually not even sure if I'm allowed to do that? It was originally made by me for Windows XP terminals that needed their Temp folders cleaned out periodically. I also put an invisible script on it http://forums.techguy.org/dos-other/644932-solved-howto-run-batch-file.html But these days, CCleaner has command prompt options, so its of no use anymore Quote echo offIf there is ONE thing I've yet to understand, it's people's obsession with files in the temp directory, and treating their deletion like some kind of ritual involving relatively complex scripts. Could not agree more...course there are 100's of other relatively simple tasks we see people attempting to write complex scripts for as well. |
|