Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Remotely clear temp folders

Hi,

I need to clear the temp folders in the file (machine names in the file )

C:\Documents and Settings\User name\Local Settings\Temporary Internet Files\Content.IE5\WHYBKXM7\sina[1].htm"

I want to delete any folder in the temporary internet files.

I want to do this remotely on a bulk no of machines.

Regards
Sharath
SOLUTION
Avatar of Brian Pierce
Brian Pierce
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bsharath

ASKER

I have done this but this does not delete all folders in the temp folder it deletes just the files
Ok it was worth a try - I'll have to leave it to the scripting gurus
          Hi Sharath
              Please try this. May take some time that it will check for every username listed in users.txt in every machine.
             for /f %x in (c:\computers.txt) do for /f %y in (c:\users.txt) do del "\\%x\c$\docume~1\%y\locals~1\tempor~1\*.*" /f /q

Regards
I get this


C:\>for /f %x in (c:\computers.txt) do for /f %y in (c:\users.txt) do del "\\%x\
c$\docume~1\%y\locals~1\tempor~1\*.*" /f /q

C:\>for /F %y in (c:\users.txt) do del "\\Dev-chen-mrd100\c$\docume~1\%y\locals~
1\tempor~1\*.*" /f /q

C:\>del "\\Dev-chen-mrd100\c$\docume~1\*****\locals~1\tempor~1\*.*" /f /q
The filename, directory name, or volume label syntax is incorrect.

C:\>del "\\Dev-chen-mrd100\c$\docume~1\Administrator\locals~1\tempor~1\*.*" /f /
q
Could Not Find \\Dev-chen-mrd100\c$\docume~1\Administrator\locals~1\tempor~1\*.*


C:\>del "\\Dev-chen-mrd100\c$\docume~1\administrator.DEVELOPMENT\locals~1\tempor
~1\*.*" /f /q
Could Not Find \\Dev-chen-mrd100\c$\docume~1\administrator.DEVELOPMENT\locals~1\
tempor~1\*.*

C:\>del "\\Dev-chen-mrd100\c$\docume~1\All\locals~1\tempor~1\*.*" /f /q
The system cannot find the path specified.

C:\>del "\\Dev-chen-mrd100\c$\docume~1\Default\locals~1\tempor~1\*.*" /f /q
The system cannot find the path specified.

C:\>del "\\Dev-chen-mrd100\c$\docume~1\LocalService\locals~1\tempor~1\*.*" /f /q

Could Not Find \\Dev-chen-mrd100\c$\docume~1\LocalService\locals~1\tempor~1\*.*

C:\>del "\\Dev-chen-mrd100\c$\docume~1\NetworkService\locals~1\tempor~1\*.*" /f
/q
Could Not Find \\Dev-chen-mrd100\c$\docume~1\NetworkService\locals~1\tempor~1\*.
*

C:\>del "\\Dev-chen-mrd100\c$\docume~1\sharathr\locals~1\tempor~1\*.*" /f /q

C:\>del "\\Dev-chen-mrd100\c$\docume~1\*****\locals~1\tempor~1\*.*" /f /q
The filename, directory name, or volume label syntax is incorrect.

C:\>del "\\Dev-chen-mrd100\c$\docume~1\Administrator\locals~1\tempor~1\*.*" /f /
q
Could Not Find \\Dev-chen-mrd100\c$\docume~1\Administrator\locals~1\tempor~1\*.*


C:\>del "\\Dev-chen-mrd100\c$\docume~1\Administrator.DEVELOPMENT\locals~1\tempor
~1\*.*" /f /q
Could Not Find \\Dev-chen-mrd100\c$\docume~1\Administrator.DEVELOPMENT\locals~1\
tempor~1\*.*

C:\>del "\\Dev-chen-mrd100\c$\docume~1\ADMINI~1~DEV\locals~1\tempor~1\*.*" /f /q

The system cannot find the path specified.

C:\>del "\\Dev-chen-mrd100\c$\docume~1\All\locals~1\tempor~1\*.*" /f /q
The system cannot find the path specified.

C:\>del "\\Dev-chen-mrd100\c$\docume~1\Default\locals~1\tempor~1\*.*" /f /q
The system cannot find the path specified.

C:\>del "\\Dev-chen-mrd100\c$\docume~1\LocalService\locals~1\tempor~1\*.*" /f /q

Could Not Find \\Dev-chen-mrd100\c$\docume~1\LocalService\locals~1\tempor~1\*.*

C:\>del "\\Dev-chen-mrd100\c$\docume~1\NetworkService\locals~1\tempor~1\*.*" /f
/q
Could Not Find \\Dev-chen-mrd100\c$\docume~1\NetworkService\locals~1\tempor~1\*.
*

C:\>del "\\Dev-chen-mrd100\c$\docume~1\sharathr\locals~1\tempor~1\*.*" /f /q

C:\>for /F %y in (c:\users.txt) do del "\\Indiasophos\c$\docume~1\%y\locals~1\te
mpor~1\*.*" /f /q

C:\>del "\\Indiasophos\c$\docume~1\*****\locals~1\tempor~1\*.*" /f /q
The filename, directory name, or volume label syntax is incorrect.

C:\>del "\\Indiasophos\c$\docume~1\Administrator\locals~1\tempor~1\*.*" /f /q
Could Not Find \\Indiasophos\c$\docume~1\Administrator\locals~1\tempor~1\*.*

C:\>del "\\Indiasophos\c$\docume~1\administrator.DEVELOPMENT\locals~1\tempor~1\*
.*" /f /q

C:\>del "\\Indiasophos\c$\docume~1\All\locals~1\tempor~1\*.*" /f /q
The system cannot find the path specified.

C:\>del "\\Indiasophos\c$\docume~1\Default\locals~1\tempor~1\*.*" /f /q
The system cannot find the path specified.

C:\>del "\\Indiasophos\c$\docume~1\LocalService\locals~1\tempor~1\*.*" /f /q
Could Not Find \\Indiasophos\c$\docume~1\LocalService\locals~1\tempor~1\*.*

C:\>del "\\Indiasophos\c$\docume~1\NetworkService\locals~1\tempor~1\*.*" /f /q
Could Not Find \\Indiasophos\c$\docume~1\NetworkService\locals~1\tempor~1\*.*

C:\>del "\\Indiasophos\c$\docume~1\sharathr\locals~1\tempor~1\*.*" /f /q
Could Not Find \\Indiasophos\c$\docume~1\sharathr\locals~1\tempor~1\*.*

C:\>del "\\Indiasophos\c$\docume~1\*****\locals~1\tempor~1\*.*" /f /q
The filename, directory name, or volume label syntax is incorrect.

C:\>del "\\Indiasophos\c$\docume~1\Administrator\locals~1\tempor~1\*.*" /f /q
Could Not Find \\Indiasophos\c$\docume~1\Administrator\locals~1\tempor~1\*.*

C:\>del "\\Indiasophos\c$\docume~1\Administrator.DEVELOPMENT\locals~1\tempor~1\*
.*" /f /q

C:\>del "\\Indiasophos\c$\docume~1\ADMINI~1~DEV\locals~1\tempor~1\*.*" /f /q
The system cannot find the file specified.

C:\>del "\\Indiasophos\c$\docume~1\All\locals~1\tempor~1\*.*" /f /q
The system cannot find the path specified.

C:\>del "\\Indiasophos\c$\docume~1\Default\locals~1\tempor~1\*.*" /f /q
The system cannot find the path specified.

C:\>del "\\Indiasophos\c$\docume~1\LocalService\locals~1\tempor~1\*.*" /f /q
Could Not Find \\Indiasophos\c$\docume~1\LocalService\locals~1\tempor~1\*.*

C:\>del "\\Indiasophos\c$\docume~1\NetworkService\locals~1\tempor~1\*.*" /f /q
Could Not Find \\Indiasophos\c$\docume~1\NetworkService\locals~1\tempor~1\*.*

C:\>del "\\Indiasophos\c$\docume~1\sharathr\locals~1\tempor~1\*.*" /f /q
Could Not Find \\Indiasophos\c$\docume~1\sharathr\locals~1\tempor~1\*.*

C:\>
         Hi Sharath
                 Maybe specified users do not exist under documents and settings. Would you please try browsing \\Indiasophos\c$\docume~1\sharathr from start>Run . Check if it exists.

Regards
Yes there is a user called sharathr
           Hi Sharath
                What happened when you browsed \\Indiasophos\c$\docume~1\sharathr   ?

Regards
I am able to see desktop,cookies,favorites all the folders
         Hi Sharath
             It looks like the following line worked
           C:\>del "\\Indiasophos\c$\docume~1\Administrator.DEVELOPMENT\locals~1\tempor~1\*
.*" /f /q

          Would you please check if temps are really deleted under administrator.development? If yes, there may be permission related issues in other profiles.

Regards
I checked the temp files were deleted but not in all profiles.

Any other method from which we can delete all the temp folders in all profiles.
          Hi Sharath
                   In profile folder of some users, Temporary Internet Files may not exist. That may be the reason why it fails in some users. For example check the \\Indiasophos\c$\docume~1\sharathr location, double-click local settings and check if "temproray internet files" folder exist.

Regards
I checked there is a folder

\\indiasophos\c$\docume~1\sharathr\Local Settings\Temporary Internet Files
        Hi Sharath
               Would you please type the following alone in cmd?
                del \\indiasophos\c$\docume~1\sharathr\Local Settings\Temporary Internet Files\*.*
                and this
                del \\indiasophos\c$\docume~1\sharathr\Locals~1\Tempor~1\*.*

Regards                
I am able to browse like this

\\indiasophos\c$\docume~1\sharathr\Local Settings\Temporary Internet Files

I get this.

C:\>del \\indiasophos\c$\docume~1\sharathr\Local Settings\Temporary Internet Files\*.*
The system cannot find the file specified.
      How about the following?
              del \\indiasophos\c$\docume~1\sharathr\Locals~1\Tempor~1\*.*
          or this one
              del \\indiasophos\c$\docume~1\sharat~1\Locals~1\Tempor~1\*.*

Regards

C:\>del \\indiasophos\c$\docume~1\sharathr\Locals~1\Tempor~1\*.*
Could Not Find \\indiasophos\c$\docume~1\sharathr\Locals~1\Tempor~1\*.*

C:\>del \\indiasophos\c$\docume~1\sharat~1\Locals~1\Tempor~1\*.*
The system cannot find the path specified.
        Hi Sharath
                Maybe Temproray internet files folder is empty?

Regards
There is a folder called

Content.IE5
Sorry i checked by creating some files and some folders.All the files are being deleted but not the folders.Can you give me to delete folders too.

       Hi Sharath
               Sorry, my mistake. Please add /s switch as below and modify the script.
              del \\indiasophos\c$\docume~1\sharathr\Locals~1\Tempor~1\*.* /f /s /q

Regards
Thanks this worked.

can you give me a total script.

Machine names should be taken from file.Autmatically it need to clear all the temp folders in all profiles.
           Hi Sharath
                 Sure
                       
                       for /f %x in (c:\computers.txt) do for /f %y in (c:\users.txt) do del "\\%x\c$\docume~1\%y\locals~1\tempor~1\*.*" /f /s /q

Regards
In users.txt what should be there in it?
             Hi Sharath
                   There should be the list of all username profile folders.
                    need to clear the temp folders in the file (machine names in the file )
C:\Documents and Settings\User name\Local Settings\Temporary Internet Files\Content.IE5\WHYBKXM7\sina[1].htm"                              ↑
                                               
                   It may prompt "The system cannot find the path specified", just ignore them because all user profiles do not exist in computer. If profile in username.txt exist in the computer, temps in it will be deleted. If not it will prompt cannot find path specified. Ignore it.
                   
Regards
FILES ARE NOT GETTING DELETED IN ALL PROFILES

C:\Documents and Settings\administrator.DEVELOPMENT\Local Settings\Temporary Internet Files

iN THE ABOVE PROFILE THERE ARE 100'S OF FILES
             Hi Sharath
                     You mention c:\. You should add this computers name to computers.txt too. And please write me the error message when it can not delete in this profile. May be an access permission issue.

Regards
I get this

C:\>for /F %y in (c:\users.txt) do del "\\dev-chen-srv400\c$\docume~1\%y\locals~
1\tempor~1\*.*" /f /s /q
The system cannot find the file c:\users.txt.
I have 6 profiles in this machine

I think all are getting cleared excluding this 1 profile.This is the Domain Administrator login.

C:\Documents and Settings\administrator.DEVELOPMENT\Local Settings\Temporary Internet Files

can we remove the users.txt
         Hi Sharath
                   Please create a users.txt in c:\ and write profile folder names like
                   admini~1
                   sharathr

                  We can not remove users.txt because Temps are not in a general path like program files.

Regards
Shouls all the users names be in the users.txt or just some users
             Hi Sharath
                      The users profile folders of computers which are in computers.txt, should be in that users.txt.

Regards
That would be difficult Mrhusy.

I need to first find all machines and then the user profiles in it.It would be difficult to get all 1000+ machine details as such.

Any other alternative solution for this.

         Hi Sharath
                Hmm, here is an other way.
                     Create a batch file named clear.bat and write following in it
                            del c:\docume~1\%username%\Local Settings\Temporary Internet Files\*.* /f /s /q
                        Then run the following
                             for /f x in (c:\computers.txt) do psexec \\%x -c c:\clear.bat -f

Regards
 
                             
i get this

C:\Pstool>for /f x in (c:\computers.txt) do psexec \\%% -c c:\clear.bat -f
in was unexpected at this time.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I get this.

C:\>psexec \\dev-chen-pc100 -c c:\clear.bat -f

PsExec v1.63 - Execute processes remotely
Copyright (C) 2001-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

C:\Windows\system32>del c:\docume~1\DEV-CHEN-PC100$\Local Settings\Temporary Int
ernet Files\*.* /f /s /q
The system cannot find the file specified.
clear.bat exited on dev-chen-pc100 with error code 1.
I have tried the same in many machines.
I think the name is missing sharathr

C:\Documents and Settings\sharathr\Local Settings\Temporary Internet Files
Any help
Any help on this......
    Thank you for accepting Sharath, i wish I could help better