Solved

Deleting cookies and temp files

Posted on 2008-10-03
9
958 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
Comment Utility
Are you using IE6 or IE7 ?

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

Author Comment

by:Smaxon
Comment Utility
IE6
0
 

Author Comment

by:Smaxon
Comment Utility
Its not deleting cookies but it deletes everthing else
0
 
LVL 3

Expert Comment

by:JJLost
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:Smaxon
Comment Utility
Thanks for that but it didnt work.
0
 
LVL 3

Expert Comment

by:JJLost
Comment Utility
second try

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

Author Comment

by:Smaxon
Comment Utility
Nope didnt work
0
 
LVL 3

Expert Comment

by:JJLost
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now