Solved

Deleting cookies and temp files

Posted on 2008-10-03
9
960 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:Smaxon
  • 5
  • 4
9 Comments
 
LVL 3

Expert Comment

by:JJLost
ID: 22634880
Are you using IE6 or IE7 ?

SET SRC2=Local Settings\Temporary Internet Files\Content.IE6
0
 

Author Comment

by:Smaxon
ID: 22635130
IE6
0
 

Author Comment

by:Smaxon
ID: 22635224
Its not deleting cookies but it deletes everthing else
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 3

Expert Comment

by:JJLost
ID: 22635284
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
0
 

Author Comment

by:Smaxon
ID: 22635445
Thanks for that but it didnt work.
0
 
LVL 3

Expert Comment

by:JJLost
ID: 22635740
second try

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

Author Comment

by:Smaxon
ID: 22650752
Nope didnt work
0
 
LVL 3

Expert Comment

by:JJLost
ID: 22651844
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 !
0
 
LVL 3

Accepted Solution

by:
JJLost earned 500 total points
ID: 22651888
EDIT:

I notice you said login so here is how to add a script to logon/logoff

1.) Start, Run, gpedit.msc
2.) Select USER Configuration, Windows Settings, Scripts (Login/Logoff)
3.) Double Click Logon or Logoff Whatever You Want*
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 Logon or Logoff (Depending on what you selected).
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
This article runs through the process of deploying a single EXE application selectively to a group of user.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question