We help IT Professionals succeed at work.

How do I clean Temporary Internet Files for all users in Windows XP/Vista using a script?

12,280 Views
Last Modified: 2013-12-08
Hello all.

I have two computers. One has Windows XP and other Windows Vista Home Premium. Both the computers have 5 user accounts.

I need a solution by which I can delete the Temporary Internet Files for all the users in one go. Currently I have a command which can delete the files for currently logged in user.

How do I delete the Temporary Internet Files for all users without manually going to the account in question and doing so?

Thanks in advance.
::Pranav::
Comment
Watch Question

Commented:
Log in as admin, if you setup Vista in classic view, then click on My Computer > select C > right click on C and select Properties > then choose Disk Clean Up > select delete files for all users on this computer.

Author

Commented:
Hi PUNKY.

Thanks a lot for lightning fast reply!

The solution you gave works, but I was hoping for a script that would do the job periodically. Or a WMI call which would automatically clean TIF. Is this possible?

Thanks!
::Pranav::

Commented:
See if this helps...

@echo off
for %%a in (%systemroot%\temp "%userprofile%\local settings\temp") do call :process %%~sa
goto :eof

:process
set fld=%1
echo y| del %fld% /f /q
for /f "delims=" %%t in ('dir %fld% /ad /b') do rmdir /s /q "%fld%\%%~t"

Save the above as Filename.bat and run the file through GPO or just manually run on the machines

From EE

Commented:
See this...
 for /f %x in (c:\computers.txt) do del \\%x\c$\windows\temp\*.* /f /s /q

https://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Q_22624563.html

Author

Commented:
Thanks bsharath for the reply. I will tryo your solutions and get back to you.

Thanks!
::Pranav::

Author

Commented:
Hi all.

bsharath your .bat file helps delete only the Windows temp folder but not the Temporary Internet Files folder. I changed it to point to TIF, but it only deletes the data for current user, not all users.

Thanks for the input.

::Pranav::

Author

Commented:
Hi all...I have written a basic VBScript which traverses through the folders in question and deletes the files. Please close this question, as I have the solution for now.

Thanks,
::Pranav::

Commented:
Great..If possible please share the code here for future reference...
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
The code above is for Windows XP. But we can do an OS specific check and use the same in Vista as well... The code above is not a perfect solution, but it does delete major junk from all profiles. If anybody has a better solution, please let me know.

Thanks!
::Pranav::

Commented:
how do you use the code above?  copy and paste it into a bat file?  copy and paste it into a txt file and rename to .vb or something similar?

Author

Commented:
Hi bsimms01.

Copy the code and save the same as a .vbs and run the script. Mind that you need to be logged in as administrator to delete files from other user's profiles and the files should not be in use. There is a further limitation in deleting files from other profiles, but I am not able to find the relevent MS KB doc at the moment.

::Pranav::

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.