Link to home
Start Free TrialLog in
Avatar of Smaxon
SmaxonFlag for United States of America

asked on

Deleting cookies and temp files

Hi all I am trying to delete the cookies from all users that log into the server,
I found this script on this site but it didnt delete the cookies could you look at this and tell me what I did wrong .

Thanks




@ECHO OFF
SET SRC1=C:\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files\Content.IE6
SET SRC3=Local Settings\History
SET SRC4=Local Settings\Temp
SET SRC5=Recent
SET SRC6=Local Settings\cookies
FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC6%\*.lnk") DO DEL /F /S /Q "%%Y"
echo About to delete files from Internet Explorer "Temporary Internet files"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
echo About to delete files from Internet Explorer "History"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Local settings\temp"
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC4%\*.*") DO RMDIR  /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC4%\*.*") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Recent" i.e. what appears in Start/Documents/My Documents
FOR /D %%X IN ("%SRC1%\*") DO FOR  %%Y IN ("%%X\%SRC5%\*.lnk") DO DEL /F /S /Q "%%Y"
echo About to delete files from "Windows\Temp"
cd /d %SystemRoot%\temp
del /F /Q *.*
@echo Y|RD /S ""
exit
Avatar of JJLost
JJLost
Flag of United States of America image

Are you using IE6 or IE7 ?

SET SRC2=Local Settings\Temporary Internet Files\Content.IE6
Avatar of Smaxon

ASKER

IE6
Avatar of Smaxon

ASKER

Its not deleting cookies but it deletes everthing else
ok this took some tweaking but try it out
Batch File:

cd\
cd C:\Documents and Settings\%username%\Local Settings\
RMDIR /S /Q "Temporary Internet Files"
echo Deleting Files
echo File Deleted
mkdir "Temporary Internet Files"
exit


let me know
Avatar of Smaxon

ASKER

Thanks for that but it didnt work.
second try

del /q /s /f "C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files\*.*"
Avatar of Smaxon

ASKER

Nope didnt work
Well, the script does what it is suppose to do however those cookies you see that are not being deleted is likely because they are locked (i.e you could likely delete them from the admin account).  The way I see it you can try two things:

1) Upgrade to Internet Explorer 7 and use the 'Empty Temporary Internet Files when Browser is closed" option

or..

2.) Run a disk cleanup at each log off
a) On the PC go Start > Run > Type  > REGEDIT /S cleanmgr.reg <
b) Next type > CLEANMGR /Sageset:1  < Check the boxes for what you want cleaned This sets your options for the following command
c) Create a .bat file with the line > CLEANMGR /sagerun:1 <
d) save it somewhere on the hard drive and add it to the shutdown scripts


To add a batch file to the shutdown scripts do the following:
1.) Start, Run, gpedit.msc
2.) Select Computer Configuration, Windows Settings, Scripts (Startup/Shutdown)
3.) Double Click Shutdown
4.) Click Add, and browse to the script.
5.) Click OK, and OK again.
6.) Close Group Policy and Restart Computer.
7.) The script should now be run on shutdown.

Let me know !
ASKER CERTIFIED SOLUTION
Avatar of JJLost
JJLost
Flag of United States of America 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