Question

Locked

Batch File to delete cookies

By detroitreds ·
I'm looking at creating a batch file to delete cookies and temp files from a remote computer. So in other words, I would manually map a drive to a computer, with the Z drive for instance, and have the batch file delete cookies and temp files to all profiles within that Z drive. Some computers have over 100 profiles, so you can see why a batch file would be useful. We're in a Windows XP environment.

This conversation is currently closed to new comments.

22 total posts (Page 1 of 3)   01 | 02 | 03   Next
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Try this

by unhappyuser In reply to Batch File to delete cook ...

Go to this link and scroll down to the Accepted Solution. It's VERY long! Good luck!

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/2000/Q_20794666.html


EMD

Collapse -

Account

by detroitreds In reply to Try this

I don't have an account with them, but thanks anyways.

Collapse -

none needed

by unhappyuser In reply to Account

You don't need one. If you scroll down far enough the solution is visible.

EMD

Collapse -

I don't see it

by detroitreds In reply to none needed

I'm looking at the page. I see about 30 replies and 1 accepted. no matter which one I choose, it's asking to create an account. The page itself isn't that long. I must be missing something.

Collapse -

Here it is

by unhappyuser In reply to I don't see it

OK try

Delete Cookies\Temp Internet, using VB (don’t panic its easy!)

source: http://support.microsoft.com/default.aspx?scid=KB;en-us;q262110

Paste the text below (not the ****) into notepad and save as "delete.vbs"
Then simply run the file

****************************************************************************************************88
Option Explicit

Private Declare Function FindFirstUrlCacheGroup Lib "wininet.dll" ( _
ByVal dwFlags As Long, _
ByVal dwFilter As Long, _
ByRef lpSearchCondition As Long, _
ByVal dwSearchCondition As Long, _
ByRef lpGroupId As Date, _
ByRef lpReserved As Long) As Long

Private Declare Function FindNextUrlCacheGroup Lib "wininet.dll" ( _
ByVal hFind As Long, _
ByRef lpGroupId As Date, _
ByRef lpReserved As Long) As Long

Private Declare Function DeleteUrlCacheGroup Lib "wininet.dll" ( _
ByVal sGroupID As Date, _
ByVal dwFlags As Long, _
ByRef lpReserved As Long) As Long

Private Declare Function FindFirstUrlCacheEntry Lib "wininet.dll" Alias "FindFirstUrlCacheEntryA" ( _
ByVal lpszUrlSearchPattern As String, _
ByRef lpFirstCacheEntryInfo As INTERNET_CACHE_ENTRY_INFO, _
ByRef lpdwFirstCacheEntryInfoBufferSize As Long) As Long

Private Type INTERNET_CACHE_ENTRY_INFO
dwStructSize As Long
szRestOfData(1024) As Long
End Type

Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" ( _
ByVal lpszUrlName As Long) As Long

Private Declare Function FindNextUrlCacheEntry Lib "wininet.dll" Alias "FindNextUrlCacheEntryA" ( _
ByVal hEnumHandle As Long, _
ByRef lpNextCacheEntryInfo As INTERNET_CACHE_ENTRY_INFO, _
ByRef lpdwNextCacheEntryInfoBufferSize As Long) As Long

Private Const CACHGROUP_SEARCH_ALL = &H0
Private Const ERROR_NO_MORE_FILES = 18
Private Const ERROR_NO_MORE_ITEMS = 259
Private Const CACHEGROUP_FLAG_FLUSHURL_ONDELETE = &H2
Private Const BUFFERSIZE = 2048

Private Sub Command1_Click()
Dim sGroupID As Date
Dim hGroup As Long
Dim hFile As Long
Dim sEntryInfo As INTERNET_CACHE_ENTRY_INFO
Dim iSize As Long

On Error Resume Next

' Delete the groups
hGroup = FindFirstUrlCacheGroup(0, 0, 0, 0, sGroupID, 0)

' To avoid error using it with IE4 as FindFirstUrlCacheGroup is not implemented
If Err.Number <> 453 Then
If (hGroup = 0) And (Err.LastDllError <> 2) Then
MsgBox "An error occurred enumerating the cache groups" & Err.LastDllError
Exit Sub
End If
Else
Err.Clear
End If

If (hGroup <> 0) Then
'we succeeded in finding the first cache group.. enumerate and
'delete
Do
If (0 = DeleteUrlCacheGroup(sGroupID, CACHEGROUP_FLAG_FLUSHURL_ONDELETE, 0)) Then

' To avoid error using it with IE4 as FindFirstUrlCacheGroup is not implemented
If Err.Number <> 453 Then
MsgBox "Error deleting cache group " & Err.LastDllError
Exit Sub
Else
Err.Clear
End If
End If
iSize = BUFFERSIZE
If (0 = FindNextUrlCacheGroup(hGroup, sGroupID, iSize)) And (Err.LastDllError <> 2) Then
MsgBox "Error finding next url cache group! - " & Err.LastDllError
End If
Loop Until Err.LastDllError = 2
End If

' Delete the files
sEntryInfo.dwStructSize = 80
iSize = BUFFERSIZE
hFile = FindFirstUrlCacheEntry(0, sEntryInfo, iSize)
If (hFile = 0) Then
If (Err.LastDllError = ERROR_NO_MORE_ITEMS) Then
GoTo done
End If
MsgBox "ERROR: FindFirstUrlCacheEntry - " & Err.LastDllError
Exit Sub
End If
Do
If (0 = DeleteUrlCacheEntry(sEntryInfo.szRestOfData(0))) _
And (Err.LastDllError <> 2) Then
Err.Clear
End If
iSize = BUFFERSIZE
If (0 = FindNextUrlCacheEntry(hFile, sEntryInfo, iSize)) And (Err.LastDllError <> ERROR_NO_MORE_ITEMS) Then
MsgBox "Error: Unable to find the next cache entry - " & Err.LastDllError
Exit Sub
End If
Loop Until Err.LastDllError = ERROR_NO_MORE_ITEMS
done:
MsgBox "cache cleared"
Command1.Enabled = True
End Sub
*************************************************************************************

Collapse -

Bat Fille

by Wizard-09 In reply to Batch File to delete cook ...

@echo off

del /Q /F "%USERPROFILE%\Cookies\*.txt"
del /Q /F "%USERPROFILE%\LocalSettings\Temp\*.*

goto

:end

Edited for mistake made on temp file del

tested now works

Keep us informed as to your progress if you require further assistance.

If you think that any of the posts that have been made by all TR Members, have solved or contributed to solving the problem, please Mark them as Helpful so that others may benefit from the outcome.

Collapse -

Question

by unhappyuser In reply to Bat Fille

This appears to only delete files in one profile. How does it delete the files in many, which I think is what they asked for?

EMD

Collapse -

Because

by Wizard-09 In reply to Question

If he was to add this to a shutdown script on AD then it will run for every user logged onto that OU when they shut down the machine.

Collapse -

Not realy what I'm looking for

by detroitreds In reply to Because

Although this might might work in AD, I'm looking at running it from a local computer. This script would only work for local profiles on the computer it's ran from. Basically, I'm looking at saving time from having to open every profile on a mapped drive and deleting the said files.

Collapse -

Makes sense

by unhappyuser In reply to Because

I assumed he wanted to remove the files from all profiles in one quick script. Thanks.

EMD

Back to Hardware Forum
22 total posts (Page 1 of 3)   01 | 02 | 03   Next

Related Discussions

Related Forums