Rosebud6 Posted September 16, 2005 Share Posted September 16, 2005 Im trying to get make a batch file that will delete the temp files and the temp internet files of the CURRENT USER and/ or all users but cant seem to get it to work.What i use now:del /Q /F /S /A c:\windows\prefetch\*.*del /Q /F /S /A C:\Docume~1\user\locals~1\temp\*.*del /Q /F /S /A C:\Docume~1\user\locals~1\Tempor~1\*.*"user" is the current user and only works for the user named "user" unless i manually change it.What i want:del /Q /F /S /A %UserProfile%\locals~1\temp\*.*del /Q /F /S /A %UserProfile%\locals~1\Tempor~1\*.*or del /Q /F /S /A %AllUserProfile%\locals~1\temp\*.*del /Q /F /S /A %AllUserProfile%\locals~1\Tempor~1\*.*When this is run, i get an error the system can not find the specified path.Is this error because it puts the full path? (IE.c:\Documents and settings\... instead of the truncated c:\docum~1\...)I guess what i need to know, is there a "universal" command to delete temp/tempinternt files from the current user or from all users? Like %UserProfile% or %AllUserProfile% to replace the user name in the path. Link to comment Share on other sites More sharing options...
InTheWayBoy Posted September 16, 2005 Share Posted September 16, 2005 Try this:del /Q /F /S /A "%UserProfile%\locals~1\temp\*.*"del /Q /F /S /A "%UserProfile%\locals~1\Tempor~1\*.*"You're getting the error because %UserProfile% = C:\Documents and Settings\User, and since there are spaces in the path you need to enclose with ""As for your goal, I can't see an easy way to do it for all users...just the current user. The All Users profile doesn't contain any temp files, so you don't need to worry about that. Link to comment Share on other sites More sharing options...
Rosebud6 Posted September 16, 2005 Author Share Posted September 16, 2005 I new it was something simple i was missing. A simple " " did the job thanks.If anyone has any ideas on how to delete from All the users and not just current user would be great. Thanks again InTheWayBoy. Link to comment Share on other sites More sharing options...
Yzöwl Posted September 16, 2005 Share Posted September 16, 2005 @ Rosebud6A simple mistake first, %ALLUSERPROFILE% should be %ALLUSERSPROFILE%What is wrong with Windows built-in tool, start » run and typecleanmgrand click OKThere are many batch files on the internet based upon this tool.Your biggest problem is that unless you get a third party solution, you should as a general rule leave well alone, most of the batch stuff you'll see on the web is downright dangerous, even on this forum.One of my first projects since moving to an XP system was to perform a similar task yours. It probably took around a year on and off, and although seemingly perfect, I still keep looking to improve it……and no it's never going to be offered Link to comment Share on other sites More sharing options...
InTheWayBoy Posted September 16, 2005 Share Posted September 16, 2005 Good call on the %ALLUSERSPROFILE% typo Link to comment Share on other sites More sharing options...
Rosebud6 Posted September 16, 2005 Author Share Posted September 16, 2005 (edited) Im a PC Tech and I just wanted a simple program i could send an end user and have it clean the temp files for them without any complex installs or configurations. One click and its done. Simple minds require simple instructions, lol. Plus cleanmgr takes alot longer. Edited September 16, 2005 by Rosebud6 Link to comment Share on other sites More sharing options...
InTheWayBoy Posted September 16, 2005 Share Posted September 16, 2005 I use this program:http://www.robertenfemke.nl/~diskclean/I have setup it up to clean everything out...all the user has to do is launch and then click a button. You can take it a step further and include it in a startup script where it will run silently. I don't know if it will handle every user profile, but it might...I used to be a PC Tech...now Network Admin so my focus has changed a little. Good luck! Link to comment Share on other sites More sharing options...
Andromeda43 Posted September 16, 2005 Share Posted September 16, 2005 (edited) Using the "del" command in a batch file won't get it!"Del" will only delete files in the prescribed folder and not in nested folders which you get a lot in the Temp folder, etc.The command you need to use is "Deltree.exe".It first showed up in DOS 6.0, I think. I've been using it ever since I first became aware of it, oh those many years ago. It's probably the most powerfull command ever put into DOS, as it deletes an entire tree structure.The command line: " deltree /y C:\*.*" will erase an entire hard drive, or any other tree structure including and below the folder prescribed in the command.So be very carefull with it! It's been eliminated in XP however, so if you want to use it, you gotta put it back. In the "\windows\system32" folder, to be exact.You'll find the XPCleanup.bat file and a copy of Deltree.exe HERE.Since it's a batch file however, you can edit it to suit your own needs. But do take a look anyway.I've added a few extra folders to it for my own use to dump some unneeded cathes, etc. I put a shortcut to it in my Startup folder for a nice little cleanup every time I reboot the PC. It's also on my desktop as part of my regular maintenance procedure.Remember, "A clean computer, is a happy computer!"Good Luck,Andromeda43 Edited September 16, 2005 by Andromeda43 Link to comment Share on other sites More sharing options...
Takeshi Posted September 16, 2005 Share Posted September 16, 2005 (edited) The script in #2 would not clean the index.dat, which gets more bloated with time.I usually clean the whole IE cache offline, deleting the whole Content.IE5 folder. Edited September 16, 2005 by Takeshi Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now